记录_Linux_SSH密钥链接【问题】
关于Linux中生成SSH密钥后,传输公钥仍连接不上的问题
实验目的
通过servera
生成的密钥,传输给fundation2
fundation2
关闭密码验证
servera
仍能链接fundation2
前提
不同虚拟机之间能够ping通
操作
servera上的操作
-
root@servera ~]# ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): /root/.ssh/servera
在/root/.ssh/
目录下创建一个密码为servera
-
ping通
fundation2
点击查看详情
[root@servera .ssh]# ping 192.168.155.128
PING 192.168.155.128 (192.168.155.128) 56(84) bytes of data.
64 bytes from 192.168.155.128: icmp_seq=1 ttl=64 time=0.579 ms
- 远程传输给
servera
点击查看代码
[root@servera .ssh]# ssh-copy-id -i /root/.ssh/servera.pub root@192.168.155.130
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/servera.pub"
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
root@192.168.155.130's password:
Number of key(s) added: 1
Now try logging into the machine, with: "ssh 'root@192.168.155.130'"
and check to make sure that only the key(s) you wanted were added.
`
- 关闭密码验证
点击查看代码
[root@servera .ssh]# vim /etc/ssh/sshd_config
PasswordAuthentication no
- 重启
SSH
安全服务
[root@servera .ssh]# systemctl reload sshd.service
fundation2上的操作
-
查看
/root/.ssh/authorized_keys
文件夹中是否有来自servera
的密钥 -
链接
ssh root@192.168.155.128
出错,
最终结果
总结
其实是servera
链接fundationa
。。。