配上ssh等效连接

配置等效连接
host1 :192.168.216.150
host2 :192.168.216.151
host3 :192.168.216.152

A.配置 host1 与 host2 的等效连接
步骤1.host1:192.168.216.150
[]$ mkdir ~/.ssh
[]$ chmod 700 ~/.ssh
[]$ ssh-keygen -t rsa
[]$ ssh-keygen -t dsa


步骤2.host2:192.168.216.151
[]$ mkdir ~/.ssh
[]$ chmod 700 ~/.ssh
[]$ ssh-keygen -t rsa
[]$ ssh-keygen -t dsa


步骤3.host1:192.168.216.150
[]$cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
[]$cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
[]$ssh 192.168.216.151 cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
[]$ssh 192.168.216.151 cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
[]$scp ~/.ssh/authorized_keys 192.168.216.151:~/.ssh/authorized_keys


步骤4:
[]$ ssh 192.168.216.151 date
[]$ ssh 192.168.216.150 date

B.配置host1与host3的等效连接

1.host3
[]$ mkdir ~/.ssh
[]$ chmod 700 ~/.ssh
[]$ ssh-keygen -t rsa
[]$ ssh-keygen -t dsa

2.host1
[]$ssh 192.168.216.152 cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
[]$ssh 192.168.216.152 cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
[]$scp ~/.ssh/authorized_keys 192.168.216.152:~/.ssh/authorized_keys


B.配置host2与host3的等效连接
host2
[]$ssh 192.168.216.152 cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
[]$ssh 192.168.216.152 cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
[]$scp ~/.ssh/authorized_keys 192.168.216.152:~/.ssh/authorized_keys


偶尔有些机器上老是配置不成功,非要在root账号下配置。
解决办法(每台机器上root账号下执行):
在ssh用户的
cd /home/mysql/.ssh
chmod 710 authorized_keys

相关推荐