1,生成SSH公鑰和私鑰服務器
ssh-keygen -t rsa Enter file in which to save the key (/root/.ssh/id_rsa): \\回車使用默認路徑 Enter passphrase (empty forno passphrase): \\使用私鑰登陸時候的密碼(建議留空) Enter same passphrase again: \\重複短語密碼 Your identification has been saved in/root/.ssh/id_rsa. Yourpublic key has been saved in/root/.ssh/id_rsa.pub. (顯示生成公鑰和私鑰的路徑)
2,添加公鑰到相關服務器裏
打開剛纔生成的.pub文件,複製裏面內容 , 在服務器裏面輸入ssh
echo "XXX(.pub裏面全部的內容)" >> /root/.ssh/authorized_keys
3,編輯sshd_config文件ide
vi /etc/ssh/sshd_config ############################################### PasswordAuthentication no \\禁用密碼驗證 RSAAuthentication yes PubkeyAuthentication yes \\啓用私鑰驗證 ################################# service sshd restar \\ 重啓服務