Linux之間配置SSH互信(SSH免密碼登錄)
阿新 • • 發佈:2017-08-02
免密碼 star class 默認 system 服務端 sshd linu ssh服務器
為簡化SSH過程,采用證書方式,免去SSH登入時需要輸入賬號密碼的過程,具體操作如下:
一、在SSH服務器所在機器上
1、以root用戶登錄,更改ssh配置文件 /etc/ssh/sshd_config,去除以下配置的註釋
RSAAuthentication yes #啟用rsa認證 PubkeyAuthentication yes #啟用公鑰私鑰配對認證方式 AuthorizedKeysFile .ssh/authorized_keys #公鑰文件路徑
2、重啟SSH服務
[[email protected] /]#systemctl restart sshd //重啟ssh服務
二、在客戶端機器上
1、生成公鑰私鑰對
[[email protected] /]#ssh-keygen -t rsa
一路默認回車,系統在/root/.ssh下生成id_rsa、id_rsa.pub
2、把id_rsa.pub發送到服務端機器上
[[email protected] /]#ssh-copy-id -i /root/.ssh/id_rsa.pub 192.168.1.20 #server ip
3、驗證
[[email protected] /]#ssh 192.168.1.20 #server ip
Linux之間配置SSH互信(SSH免密碼登錄)