目 的: sitea 使用 ssh 連至 siteb 時不提示密碼
本地端: sitea.com.tw (sitea)
遠 端: siteb.com.tw (siteb)
在 sitea 使用 ssh-keygen 建立共用/私有金鑰
[root@sitea ~]# ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
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:
5e:8c:33:a6:60:44:fd:63:fc:f6:03:c6:43:74:65:ca root@sitea.com.tw
將 sitea 的共用金鑰傳送至 siteb
[root@sitea .ssh]# scp id_rsa.pub avai@siteb.com.tw:~/id_rsa.pub
id_rsa.pub 100% 239 0.2KB/s 00:00
[root@sitea .ssh]#
使用 ssh 連入 siteb 設定共用金鑰
[root@sitea .ssh]# ssh avai@siteb.com.tw
avai@siteb.com.tw’s password:
[avai@siteb ~]$ mkdir .ssh
[avai@siteb ~]$ mv id_rsa.pub .ssh/authorized_keys
[avai@siteb ~]$ exit
再次使用 ssh 連至 siteb 就不會再提示密碼了
[root@sitea ~]# ssh avai@siteb.com.tw
Last login: Fri May 30 22:30:00 2008 from xx-xx-xx-xx.sitea-ip.com.tw
[avai@siteb ~]$






發表於: 週二, 八月 19, 2008
標籤: linux, ssh