[root@localhost ~]# passwd xiaoming
Changing password for user xiaoming.
New password:
BAD PASSWORD: The password is shorter than 8 characters
Retype new password:
passwd: all authentication tokens updated successfully.
[root@localhost ~]# passwd xiaohei
Changing password for user xiaohei.
New password:
BAD PASSWORD: The password is shorter than 8 characters
Retype new password:
passwd: all authentication tokens updated successfully.
三、在xiaoming用户端创建密钥对
[xiaoming@localhost ~]$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/xiaoming/.ssh/id_rsa):
Created directory '/home/xiaoming/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/xiaoming/.ssh/id_rsa.
Your public key has been saved in /home/xiaoming/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:BecU8MUqdq0KmETpPNGLUEx8WaYWqGoT6wFUooAKD9M xiaoming@localhost.localdomain
The key's randomart image is:
+---[RSA 3072]----+
|oo.*o+.o=.+o. |
|B.E B ++ * .. |
|=+ * +o. +o |
|o.o *.. o.o . |
|..o. + .So . |
|.= o . . |
|o o . . |
| . . |
| |
+----[SHA256]-----+
四、把创建的公钥文件复制到xiaoming用户和xiaohei用户的服务端目录下
[xiaoming@localhost ~]$ ssh-copy-id xiaoming@192.168.190.133
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/home/xiaoming/.ssh/id_rsa.pub"
The authenticity of host '192.168.190.133 (192.168.190.133)' can't be established.
ECDSA key fingerprint is SHA256:BZo7UCK5RNPgKV+RMQA3ftl+Opx5Y5uU14fVznlw0Ts.
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
xiaoming@192.168.190.133's password:
Number of key(s) added: 1
Now try logging into the machine, with: "ssh 'xiaoming@192.168.190.133'"
and check to make sure that only the key(s) you wanted were added.
[xiaoming@localhost ~]$ ssh-copy-id xiaohei@192.168.190.133
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/home/xiaoming/.ssh/id_rsa.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
xiaohei@192.168.190.133's password:
Number of key(s) added: 1
Now try logging into the machine, with: "ssh 'xiaohei@192.168.190.133'"
and check to make sure that only the key(s) you wanted were added.
五、登录验证
[xiaoming@localhost ~]$ ssh xiaohei@192.168.190.133
4.18.0-348.el8.x86_64
Red Hat Enterprise Linux release 8.5 (Ootpa)
localhost.localdomain
/bin/bash
Activate the web console with: systemctl enable --now cockpit.socket
This system is not registered to Red Hat Insights. See https://cloud.redhat.com/
To register this system, run: insights-client --register
[xiaohei@localhost ~]$