配置ssh的双机信任

背景:

两台服务器ssh登录,不用输密码!!!


试验环境:

vmware workstation 11

服务器A:ip:192.168.0.19

服务器B:ip:192.168.0.12

SecureCRT (ssh远程连接软件)


实验过程:

一、生成密钥

[root@baculaServer  ~]# 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:

43:2e:ab:3d:1e:7a:7b:39:78:78:8f:71:e9:6e:39:44 root@baculaServer 

The key's randomart image is:

+--[ RSA 2048]----+

|                 |

|                 |

|        .        |

|       o  E      |

|      . S.       |

|       o ...     |

|      oo.oo.     |

|     +=.*=+      |

|    oo+*.=+.     |

+-----------------+


二、公钥发送到另一台服务器

[root@baculaServer  ~]# ssh-copy-id -i /root/.ssh/id_rsa.pub [email protected]

The authenticity of host '192.168.0.12 (192.168.0.12)' can't be established.

RSA key fingerprint is fb:60:11:0b:20:da:e0:27:f0:b2:13:13:57:7c:00:77.

Are you sure you want to continue connecting (yes/no)? yes

Warning: Permanently added '192.168.0.12' (RSA) to the list of known hosts.

[email protected]'s password: 

Now try logging into the machine, with "ssh '[email protected]'", and check in:


  .ssh/authorized_keys


to make sure we haven't added extra keys that you weren't expecting.


另一台上面进行相同操作!!!

测试:

服务器:192.168.0.19

[root@baculaServer  ~]# ssh [email protected]

Last login: Mon Mar 14 00:31:53 2016 from 192.168.0.31

[root@Slave-drbd ~]# ifconfig

eth0      Link encap:Ethernet  HWaddr 00:0C:29:86:D2:12  

          inet addr:192.168.0.12  Bcast:192.168.0.255  Mask:255.255.255.0



服务器:192.168.0.12

[root@Slave-drbd ~]# ssh [email protected]

Last login: Mon Mar 14 00:16:22 2016 from 192.168.0.31

[root@baculaServer  ~]# 



总结:简单的很这样操作。

你可能感兴趣的:(ssh,信任,双机)