LoginSignup
7
10

More than 5 years have passed since last update.

さくらのVPSにUbuntu16.04を入れて初期設定するまでのメモ

Last updated at Posted at 2016-07-05

インストール

さくらのサポート情報を読んでセットアップ。

-bash: warning: setlocale: LC_ALL: cannot change locale (ja_JP.UTF-8)というエラーが出る場合は、sudo apt-get -y install language-pack-jaでランゲッジパックを入れる。

パッケージのアップデートなど  

# パッケージを更新
$ sudo apt-get update && upgrade
# vimをインストール
$ sudo apt-get install vim
#.bashrc、.bash_profileを設定
$ vim ~/.bashrc
$ vim ~/.bash_profile
# gitをインストール
$ sudo apt-get install git
# 自分のGithubリポジトリからDotfilesをインストール
$ git clone xxxxx

Dotfilesの.vimrc, .vimにシンボリックリンクを張る

ln -s ~/Dotfiles/.vimrc ~/.vimrc
ln -s ~/Dotfiles/.vim ~/.vim

ホスト名を変更
/etc/hostnameの名前を変更。
/etc/hostsの名前を変更

Githubへ接続するためのssh設定

# .sshディレクトリを作成
$ mkdir ~/.ssh
# 公開鍵、秘密鍵を作成。
$ ssh-keygen -t rsa
# id_rsa.pubの中身をコピー
$ cat id_rsa.pub

githubに公開鍵(id_rsa.pub)を登録

自分のPCからサーバーへ接続するためのssh設定

自分のPCの~/.ssh配下へconfigファイルをつくる

~/.ssh/config
Host xxxxx
    HostName xxx.xxx.xxx.xxx
    Port xxx
    User xxxxx

pcのid_rsa.pubをサーバーに送る
scp -P 22 ~/.ssh/id_rsa.pub xxx@xxx.xxx.xxx.xxx:/home/username
serverのauthorizedkeysに登録
cat ~/id_rsa.pub >> ~/.ssh/authorizedkeys

ファイヤーウォール設定

#現状確認
$ sudo ufw status
Status: inactive

#デフォルトで全てのポートを無効にする
$ sudo ufw default deny
Default incoming policy changed to 'deny'
(be sure to update your rules accordingly)

#ファイアウォールを有効化
$ sudo ufw enable
Command may disrupt existing ssh connections. Proceed with operation (y|n)? y
Firewall is active and enabled on system startup

# 許可するポートを指定
$ sudo ufw allow http
$ sudo ufw allow https
$ sudo ufw allow xxxxx #sshのデフォルトポート

#反映
$ sudo ufw reload

参考サイト

CUBE SUGER STORAGE
Ubuntu14.04でホスト名を変更する
Ubuntu LTS 14.02をさくらVPSで立てたメモ

7
10
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
10