无密码登陆

server A /B
 
以root账户在A上无密码ssh到B
方式一
ON A:
ssh-keygen -t dsa -P '' -f ~/.ssh/id_dsa
cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
chmod 644  ~/.ssh/authorized_keys
service sshd restart

 

ON B:
ssh-keygen -t dsa -P '' -f ~/.ssh/id_dsa
cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
chmod 644  ~/.ssh/authorized_keys

scp -r root@A:/root/.ssh/id_dsa.pub     /root/.ssh/master_dsa.pub
cat ~/.ssh/master_dsa.pub >> ~/.ssh/authorized_keys
service sshd restart
 
 

 note:上面ssh-keygen生成的文件id_dsa不能修改为其他的名称,否则会导致SSH无法生效。

 

 方式二

serverA无密码登陆 serverB

在serverA上

 

ssh-keygen -t rsa -P '' -f ~/.ssh/id_rsa
ssh-copy-id -i ~/.ssh/id_rsa.pub  ll2v@serverB

然后可以再serverA上无密码登陆到serverB了

posted @ 2016-09-08 16:19  simplelg17  阅读(130)  评论(0编辑  收藏  举报