centos7下配置免密码登录

主机master ,slaver1,slaver2

1、每台主机都执行

  ssh-keygen -t rsa

 

然后一直回车

2、操作master。master生成公钥 放入authorized_keys文件中,然后发送个slave1,记住只发送给slave1不要发送给slaver2

  cd ~/.ssh

  cat id_rsa.pub >> authorized_keys

  scp ~/.ssh/authorized_keys slave1:~/.ssh/
 

3、操作slaver1。slaver1生成公钥 放入authorized_keys文件中,然后发送个slave1,记住只发送给slave1不要发送给master(相当于往authorized_keys添加三台主机的公钥)

 

  cd ~/.ssh

  cat id_rsa.pub >> authorized_keys

  scp ~/.ssh/authorized_keys slave2:~/.ssh/

 4、操作slaver2。slaver2生成公钥 放入authorized_keys文件中,然后发送个slave1和master

  

  cd ~/.ssh

  cat id_rsa.pub >> authorized_keys

  scp ~/.ssh/authorized_keys slave1:~/.ssh/
 scp ~/.ssh/authorized_keys slave2:~/.ssh/
注意:一定要按上面的步骤一步一步来,如果不小心弄错了,删掉每台机器的.ssh文件然后重新执行。

参考:https://www.jianshu.com/p/991b39c48b0f

  

转载于:https://www.cnblogs.com/zml-java/p/9448281.html

你可能感兴趣的:(运维)