1、在主服务器master下生成密钥
$ ssh-keygen -t dsa -P ” -f ~/.ssh/id_dsa
2、将密钥放在 ~/.ssh/authorized_keys
$ cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
3、对生成的文件authorized_keys授权
chmod 600 ~/.ssh/authorized_keys
4、编辑sshd_config文件,将下面三列#去掉
vim /etc/ssh/sshd_config
RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys
5、重启sshd 服务(可省略)
service sshd restart
6、验证无验证登陆
ssh localhost
7 配置master无密钥登陆slave(以此可以配置master无密钥登陆slaveX)
注释:root为root用户,master为主机名
[root@slaver ~]# scp -r root@master :/root/.ssh/id_dsa.pub /root/.ssh/slaver.pub
[root@slaver ~]# cat ~/.ssh/slaver.pub >> ~/.ssh/authorized_keys
chmod 600~/.ssh/authorized_keys
vim /etc/ssh/sshd_config
RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys
service sshd restart
CentOS 下SSH无密码登录的配置 http://www.linuxidc.com/Linux/2012-05/61346.htm
Linux下实现SSH无密码验证登陆 http://www.linuxidc.com/Linux/2014-01/95917.htm
Ubuntu和CentOS如何配置SSH使得无密码登陆 http://www.linuxidc.com/Linux/2014-01/94794.htm
本文永久更新链接地址:http://www.linuxidc.com/Linux/2014-06/102664.htm