多linux服务器间ssh密钥登陆

 

 

举例:A主机与B主机都可以无密码登陆C主机

 

1. A机上运行:ssh-keygen -t rsa

2. A机上运行:scp /root/.ssh/id_rsa.pub c_IP:/root/.ssh/authorized_keys

3. B机上运行:ssh-keygen -t rsa

4. B机上运行:scp /root/.ssh/id_rsa.pub c_IP:/root/.ssh/authorized_keys_b  

5. 登录到C机,进入/root/.ssh下

6. C机上运行:cat authorized_keys_b >> authorized_keys.

现在,A,B机都能够无需密码登录到C机,使用scp传输文件也不用输入密码。

 

 

命令运行情况如下:一路回车,使用默认

 

[root@www ~]# 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.

The key fingerprint is:

f8:6d:5b:10:c2:10:d5:26:d4:ec:ab:87:1e:a2:65:5d [email protected]

 

你可能感兴趣的:(linux,无密码登陆,多主机,SSH密钥,无密码传输)