0.SSHを自動化、rsync等でパスワードなしで接続するための設定(証明書鍵の交換)

1.秘密鍵と公開鍵の作成(コピー元サーバ)

# ssh-keygen -t rsa -N ""
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx root@ホスト名
  • インストールディレクトリを聞いてきますのでそのままEnterを押します。
  • 以上のコマンドを実行すると、~/.ssh/ディレクトリにid_dsa(秘密鍵)とid_dsa.pub(公開鍵)が作成されます。

2.公開鍵をコピー先サーバにコピーする

# scp -p ~/.ssh/id_rsa.pub xxx.xxx.xxx.xxx:~/.ssh/

3.公開鍵を~/.ssh/authorized_keysに追加する(コピー先サーバ)
 *ディレクトリのアクセス権を間違えるとうまく動作しませんので注意!

# cd ~/.ssh
# cat id_rsa.pub >> authorized_keys
# rm id_rsa.pub 
# chmod 600 authorized_keys
最終更新:2009年07月16日 12:50