配置等效连接
host1 :192.168.216.150
host2 :192.168.216.151
host3 :192.168.216.152
A.配置 host1 与 host2 的等效连接
步骤1.host1:192.168.216.150
[[email protected]]$ mkdir ~/.ssh
[[email protected]]$ chmod 700 ~/.ssh
[[email protected]]$ ssh-keygen -t rsa
[[email protected]]$ ssh-keygen -t dsa
步骤2.host2:192.168.216.151
[[email protected]]$ mkdir ~/.ssh
[[email protected]]$ chmod 700 ~/.ssh
[[email protected]]$ ssh-keygen -t rsa
[[email protected]]$ ssh-keygen -t dsa
步骤3.host1:192.168.216.150
[[email protected]]$cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
[[email protected]]$cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
[[email protected]]$ssh 192.168.216.151 cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
[[email protected]]$ssh 192.168.216.151 cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
[[email protected]]$scp ~/.ssh/authorized_keys 192.168.216.151:~/.ssh/authorized_keys
步骤4:
[[email protected]]$ ssh 192.168.216.151 date
[[email protected]]$ ssh 192.168.216.150 date
B.配置host1与host3的等效连接
1.host3
[[email protected]]$ mkdir ~/.ssh
[[email protected]]$ chmod 700 ~/.ssh
[[email protected]]$ ssh-keygen -t rsa
[[email protected]]$ ssh-keygen -t dsa
2.host1
[[email protected]]$ssh 192.168.216.152 cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
[[email protected]]$ssh 192.168.216.152 cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
[[email protected]]$scp ~/.ssh/authorized_keys 192.168.216.152:~/.ssh/authorized_keys
B.配置host2与host3的等效连接
host2
[[email protected]]$ssh 192.168.216.152 cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
[[email protected]]$ssh 192.168.216.152 cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
[[email protected]]$scp ~/.ssh/authorized_keys 192.168.216.152:~/.ssh/authorized_keys
偶尔有些机器上老是配置不成功,非要在root账号下配置。
解决办法(每台机器上root账号下执行):
在ssh用户的
cd /home/mysql/.ssh
chmod 710 authorized_keys
原文地址:https://www.cnblogs.com/hxlasky/p/12204180.html