一、在A機上配置
①以root用戶登錄,更改ssh配置文件
vi /etc/ssh/sshd_config
RSAAuthentication yes #啟用rsa認證
PubkeyAuthentication yes #啟用公鑰私鑰配對認證方式
AuthorizedKeysFile .ssh/authorized_keys #公鑰文件路徑
systemctl restart sshd //重啟ssh服務
②生成公鑰私鑰對
ssh-keygen -t rsa
系統在/root/.ssh下生成id_rsa、id_rsa.pub
③把A機下的id_rsa.pub發送到A、B、C機
ssh-copy-id -i /root/.ssh/id_rsa.pub 192.168.10.122
ssh-copy-id -i /root/.ssh/id_rsa.pub 192.168.10.125
ssh-copy-id -i /root/.ssh/id_rsa.pub 192.168.20.11
二、B、C機采用步驟一中相同的方法,要記得改變ip地址
三、實現ssh多機互信
以A機為例
ssh 192.168.10.122 //登錄B機
ifconfig //檢查是否成功登錄
exit //退出ssh登錄,返回本機
添加新的機器
新機器D:
①以root用戶登錄,更改ssh配置文件
②生成公鑰私鑰對
③把D機下的id_rsa.pub發送到A機
分發A機的.ssh/authorized_keys到其他機器上