不用密碼直接用 ssh 登入到遠端電腦
SSH 公開金鑰認證(Public Key Authentication)使用方式
用密碼直接用 ssh 登入到遠端電腦(配合 rsync 使用)。
(A 電腦)frog.cgsh.tc.edu.tw
(B 電腦)cgblue.cgsh.tc.edu.tw
- 在(A 電腦)上製作 public keys & private keys
- 將 id_dsa.pub (public keys)放到 cgblue.cgsh.tc.edu.tw 上,並加入 authorized_keys 中。
- scp id_dsa.pub root@cgblue.cgsh.tc.edu.tw:~/id_dsa_frog.pub
- 登入 root@cgblue.cgsh.tc.edu.tw
- cat id_dsa_steven.pub >> .ssh/authorized_keys
- 在 (A 電腦)frog.cgsh.tc.edu.tw 上執行
ssh root@cgblue.cgsh.tc.edu.tw 不用輸入密碼就直接登入了。
在 frog.cgsh.tc.edu.tw 中執行 rsync 指令即可不用輸入密碼。
rsync –delete -ave ssh root@cgblue.cgsh.tc.edu.tw:/var/www/html/gallery3 /home/gallery3

參考文章:https://blog.gtwang.org/linux/linux-ssh-public-key-authentication/
