Monday, June 18, 2012

SSHアクセスのセットアップ (サーバー)

Publicキーができたところで今度はサーバーに移しauthorized_keysへ追記する必要がある。

1. パブリックキーをサーバーの任意のフォルダへコピー
2. サーバーにコピーされたキーをauthorized_keysへ追記
3. 元のパブリックキーを消去
(サーバーに~/.sshフォルダやauthorized_keysがない場合は下記を参照)

1. パブリックキーをサーバーの任意のフォルダへコピー

構文
scp (ローカルのパブリックキー) (ユーザー名)@(IP アドレス):(パブリックキーを移動させたいフォルダ)
scp ~/.ssh/id_rsa.pub user@remote.server.com:/home/username

2. サーバーにコピーされたキーをauthorized_keysへ追記
cat  /home/username/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
3. 元のパブリックキーを消去
rm /home/username/.ssh/id_rsa.pub
 もしサーバーに~/.sshフォルダやauthorized_keysが見当たらない場合


1. SSHでログインする2. ~/.sshフォルダを作る
3. authorized_keysファイルを作る



1. SSHでログインする
ssh username@ipaddress
2. ~/.sshフォルダを作る
mkdir ~/.ssh
/home/username/.sshフォルダが作成される


3. authorized_keysファイルを作る
touch authorized_keys
これで空のauthorized_keysファイルが出来る

サーバーを借りてからまず最初にすること (Ubuntu)

覚書として、サーバーを借りてからの初期設定を書いておく
(環境はMac OSクライアントにUbuntuサーバー)
1. サーバーにSSHでアクセス
2. ユーザーのパスワードの変更
3. OSのバージョンチェック


1. サーバーにSSHでアクセス
Terminalを開き
ssh (username)@(server ipaddress)


2. ユーザーのパスワードの変更
パスワードを変更したいユーザーでログインした状態で以下のコマンド打つ
psswd

3. OSのバージョンチェック

$ cat /etc/issue 
以下のような結果がえられるはず、
Ubuntu 11.04 \n \l