当前位置:   article > 正文

Linux服务器与客户端实现相互SSH免密登录_/bin/ssh-copy-id: info: source of key(s) to be ins

/bin/ssh-copy-id: info: source of key(s) to be installed: "/root/.ssh/id_rsa

服务器: IPV4 192.168.78.129
客户端: IPV4 192.168.78.130

一、准备阶段:
1. systemctl disable firewalld    #关闭防火墙
2. setenforce 0                          #关闭setenforce
3. getenforce                             #查看setenforce 的状态

二、配置
[root@localhost ~]# ssh-keygen -t rsa

[root@localhost ~]# ll /root/.ssh/   #查看密钥匙目录
total 8
-rw------- 1 root root 2610 Nov 21 08:46 id_rsa       #私钥文件
-rw-r--r-- 1 root root  580 Nov 21 08:46 id_rsa.pub   #公钥文件

[root@localhost ~]# ssh-copy-id root@192.168.78.130   #复制SSH公钥到客户端主机
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"
The authenticity of host '192.168.78.130 (192.168.78.130)' can't be established.
ED25519 key fingerprint is SHA256:NKL8tu+PvR+9Tpp+W0/GwDh8gzQqRsCbaSPTBWgLBfw.
This key is not known by any other names
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
/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.78.130's password: 

Number of key(s) added: 1

Now try logging into the machine, with:   "ssh 'root@192.168.78.130'"
and check to make sure that only the key(s) you wanted were added.


[root@localhost ~]# ssh 192.168.78.130  #实现免密登入客户端主机
Activate the web console with: systemctl enable --now cockpit.socket

Register this system with Red Hat Insights: insights-client --register
Create an account or view all your systems at https://red.ht/insights-dashboard
Last login: Tue Nov 21 08:40:00 2023 from 192.168.78.1

免密登入成功!!!!

客户端免密访问服务器
[root@client ~]# ssh-keygen -t rsa

[root@client ~]# ll /root/.ssh/    #查看密钥目录
total 20
-rw------- 1 root root  580 Nov 21 08:52 authorized_keys  #服务器免密访问客户生成的密钥
-rw------- 1 root root 2602 Nov 21 08:54 id_rsa           #私钥文件
-rw-r--r-- 1 root root  565 Nov 21 08:54 id_rsa.pub       #公钥文件
-rw------- 1 root root  840 Nov 21 08:55 known_hosts      #记录服务器发来的公钥信息
-rw-r--r-- 1 root root   96 Nov 21 08:55 known_hosts.old  #存储之前连接过的SSH服务器的公钥

[root@client ~]# ssh 192.168.78.129
Activate the web console with: systemctl enable --now cockpit.socket

Register this system with Red Hat Insights: insights-client --register
Create an account or view all your systems at https://red.ht/insights-dashboard
Last login: Tue Nov 21 08:39:48 2023 from 192.168.78.1

登录成功!!!!

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/AllinToyou/article/detail/187751
推荐阅读
相关标签
  

闽ICP备14008679号