什么是广告艺术设计苏州网站seo优化
配置ssh免密登陆,能够通过客户端主机通过redhat用户和服务端主机基于公钥验证方式进行远程连接
1.客户端创建redhat用户
[root@node2-client ~]# useradd redhat
[root@node2-client ~]# passwd redhat
Changing password for user redhat.
New password: Admin123!
BAD PASSWORD: The password fails the dictionary check - it is based on a dictionary word
Retype new password: Admin123!
passwd: all authentication tokens updated successfully.
2.切换用户,创建密钥对
[root@node2-client ~]# su - redhat # 切换redhat用户
[redhat@node2-client ~]$ ssh-keygen -t rsa # 生成ssh密钥对,这个密钥对能够用于ssh协议的身份验证 ;-t 指定要生成的密钥类型
Generating public/private rsa key pair.
Enter file in which to save the key (/home/redhat/.ssh/id_rsa): 回车 # 直接回车是选择密钥对保存路径为默认的 /home/redhat/.ssh/;也可自定义密钥保存位置
Created directory '/home/redhat/.ssh'.
Enter passphrase (empty for no passphrase): 回车 # 直接回车表示不使用密码保护所生成的密钥,也可输入密码
Enter same passphrase again: 回车 # 确认密码
Your identification has been saved in /home/redhat/.ssh/id_rsa
Your public key has been saved in /home/redhat/.ssh/id_rsa.pub
The key fingerprint is:
SHA256:hxjKgDkqPO8wK/v18/A9v/Q6CH4FGK6Z+Ko4oqW2JcY redhat@node2-client
The key's randomart image is:
+---[RSA 3072]----+
| |
| o . |
|+ . .. o |
|o. o . oo.. |
|oo o..+S .. |
|o o . + .. . |
| E.o.... . o. |
|==B. .oo..+... |
|X*+o...oo..o++. |
+----[SHA256]-----+
[redhat@node2-client ~]$ ll /home/redhat/.ssh/ # 查看密钥对是否生成
total 16
-rw-------. 1 redhat redhat 2602 Mar 28 09:01 id_rsa
-rw-r--r--. 1 redhat redhat 573 Mar 28 09:01 id_rsa.pub
-rw-------. 1 redhat redhat 840 Mar 28 09:02 known_hosts
-rw-r--r--. 1 redhat redhat 96 Mar 28 09:02 known_hosts.old
3.将本地ssh公钥复制到服务端,实现无密码登录服务器
[redhat@node2-client ~]$ ssh-copy-id root@192.168.11.135 # 将本地的 SSH 公钥复制到远程服务器,从而实现通过 SSH 密钥进行无密码登录远程服务器
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/home/redhat/.ssh/id_rsa.pub"
The authenticity of host '192.168.11.135 (192.168.11.135)' can't be established.
ED25519 key fingerprint is SHA256:ZnGXKVJ+y39gUJ9gZt38DNRkuNByInVUXuzKoMS4MIg.
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.11.135's password: root
Number of key(s) added: 1
Now try logging into the machine, with: "ssh 'root@192.168.11.135'"
and check to make sure that only the key(s) you wanted were added.
4.ssh远程免密连接测试
[redhat@node2-client ~]$ ssh root@192.168.11.135
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: Fri Mar 28 08:51:56 2025 from 192.168.11.1
[root@node1-server ~]# logout # 登出
Connection to 192.168.11.135 closed.