server A /B
以root账户在A上无密码ssh到B
方式一
ON A:
ssh-keygen -t dsa -P '' -f ~/.ssh/id_dsacat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keyschmod 644 ~/.ssh/authorized_keysservice sshd restart
ON B:
ssh-keygen -t dsa -P '' -f ~/.ssh/id_dsacat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keyschmod 644 ~/.ssh/authorized_keysscp -r root@A:/root/.ssh/id_dsa.pub /root/.ssh/master_dsa.pubcat ~/.ssh/master_dsa.pub >> ~/.ssh/authorized_keysservice sshd restart
note:上面ssh-keygen生成的文件id_dsa不能修改为其他的名称,否则会导致SSH无法生效。
方式二
serverA无密码登陆 serverB
在serverA上
ssh-keygen -t rsa -P '' -f ~/.ssh/id_rsassh-copy-id -i ~/.ssh/id_rsa.pub ll2v@serverB
然后可以再serverA上无密码登陆到serverB了