centos7.3 linux之间设置ssh无密码互相访问

上一篇 / 下一篇  2017-11-28 11:02:52 / 个人分类:Linux

1.在每台服务器上都执行ssh-keygen -t rsa 生成密钥
ssh-keygen -t rsa

Generating public/private rsa key pair.
 Enter file in which to save the key (/root/.ssh/id_rsa): #回车代表无需密码登陆
Enter passphrase (empty for no passphrase): #回车
Enter same passphrase again: #回车
Your identification has been saved in /root/.ssh/id_rsa. #私钥(不需要操作)
Your public key has been saved in /root/.ssh/id_rsa.pub. #公钥(不需要操作)

2.进入 .ssh文件夹,创建authorized_keys文件,并赋予权限
cd /root/.ssh
touch authorized_keys
chmod 644 authorized_keys
chmod 700 ~/.ssh

3.将公钥导入到authorized_keys文件
ssh 10.204.125.86 cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
注:
a.如不行,直接将id_rsa.pub中生成的密钥复制到每台机器authorized_keys中。
b.还不行,重新执行ssh-keygen -t rsa 生成密钥,复制到每台机器authorized_keys中。

4.如还不行,请调试ssh
 ssh -vvv -p 22 root@isky1
查看日志

日志报错找不到id_isa

删掉之前,重新换秘钥生成
ssh-keygen -t dsa

其他步骤同上,不行继续查看日志


TAG: Linux linux

 

评分:0

我来说两句

显示全部

:loveliness: :handshake :victory: :funk: :time: :kiss: :call: :hug: :lol :'( :Q :L ;P :$ :P :o :@ :D :( :)

Open Toolbar