Linux虚拟机之间实现密钥登陆

Server1与Server2在同一虚拟网络当中,在Server2中使用Server1的Hostname连接Server1,并且无需密码认证。

Server1,  Hostname:  hlmvmeast652           Internal IP:  192.168.0.5

Server2,  Hostname:  hlmvmeast653           Internal IP:  192.168.0.6

1.在Server1中生成密钥对

 

2.在Server2中创建/root/.ssh

 

3.将Server1中的公钥id_rsa.pub拷贝给Server2,Server2将这个文件放置在/root/.ssh下,改名为authorized_keys。

操作命令scp /root/.ssh/id_rsa.pub 192.168.0.6:/root/.ssh/authorized_keys

 

4. Server1连接server2,发现还需要密码

 

5.将Server2中selinux设置为Permissive的状态

 

6.再次在Server1中连接Server2,发现可以无密码成功连接

 

7.也可以使用主机名进行连接

 

I hear and I forget. I see and I remeber. I do and I understand!
原文地址:https://www.cnblogs.com/stonehe/p/7486116.html