赞
踩
服务器: 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
登录成功!!!!
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。