ubuntu14.04(Linux全般)同士でノンパスワードでSSHできるようにする
サーバー側の操作
秘密鍵と公開鍵を作成する
$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/hoge/.ssh/id_rsa):
Enter passphrase (empty for no passphrase): #クライアント側操作で必要に>なるパスワードなので覚えておくこと
Enter same passphrase again:
Your identification has been saved in /home/hoge/.ssh/id_rsa.
Your public key has been saved in /home/hoge/.ssh/id_rsa.pub.
The key fingerprint is:
70:6c:0b:45:5b:77:31:bc:4e:b7:21:01:39:82:92:2e hoge@fuga
The key's randomart image is:
+--[ RSA 2048]----+
| ..+ ..+.+. |
| o + + + o.. |
| . + = . . .. |
| E . = . .o..|
| . S o..o|
| .. |
| |
| |
| |
+-----------------+
$ cat $HOME/.ssh/id_rsa.pub >> $HOME/.ssh/authorized_keys
$ chmod 600 $HOME/.ssh/authorized_keys
クライアント側の操作
何らかの方法で先ほど作成したid_rsaファイルをクライアントマシンにコピーする ここではscpを使う
$ scp サーバーのipアドレス:.ssh/id_rsa ./
秘密鍵を登録する
$ ssh-add id_rsa
Enter passphrase for id_rsa: #サーバー側操作で入力したパスフレーズ
Identity added: id_rsa (id_rsa)
これで、ノンパスワードでログインできる。