配置ssh远程连接
1.实现两台linux主机之间通过公钥验证能够互相实现免密登陆
步骤:
第一步:定位客户端,制作公私钥对
[root@server ~]# ssh-keygen -t rsa # 一路回车
第二步:定位客户端,将公钥上传到服务器端
[root@node1 ~]# ssh-copy-id root@192.168.48.130 # 输入服务端的账户及IP地址
The authenticity of host '192.168.48.130 (192.168.48.130)' can't be established.
ED25519 key fingerprint is SHA256:K7nvJFkfIh+p9YytEGR44wLbTfpB0Y52oVou0UdG6nc.
This key is not known by any other names
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes # 输入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.48.130's password: # 输入服务端root账户的的密码Number of key(s) added: 1
Now try logging into the machine, with: "ssh 'root@192.168.48.130'"
and check to make sure that only the key(s) you wanted were added.# 注意:客户端将公钥上传到服务器端后,服务器端的/root/.ssh/authorized_keys文件会存储客户端的公钥数据
第三步:客户端测试
[root@node1 ~]# ssh root@192.168.48.130
Activate the web console with: systemctl enable --now cockpit.socketRegister 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: Wed Mar 22 11:31:31 2023
[root@server ~]#
第四步:由于是要实现服务端与客户端相互免密,则将上述操作在服务端在执行一遍
运行截图: