[root@server ~]# yum install openssh-server -y #安装ssh服务[root@server ~]# useradd redhat #2:在server创建redhat用户[root@server ~]# passwd redhat #给redhat创建密码为123
Changing password for user redhat.
New password:
BAD PASSWORD: The password is shorter than 8 characters
Retype new password:
passwd: all authentication tokens updated successfully.
2:node1配置
[root@node1 ~]# yum install openssh-server -y #安装ssh服务[root@node1 ~]# ssh-keygen -t rsa #1:定位node1,注册公私钥对,一直按回车
Generating public/private rsa key pair.
Enter fileinwhich to save the key (/root/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa
Your public key has been saved in /root/.ssh/id_rsa.pub
The key fingerprint is:
SHA256:Z6OExfCWSjTpENxWrFm01yJvH6XKmUMoFJ9RvXl0zow root@node1
The key's randomart image is:
+---[RSA 3072]----+
| ..o==+... |
| o.+Bo= .. . .|
| +o+@ o .+.* |
| o+= = .ooE +|
| + S B o. |
| o B * . |
| . * . |
| . |
| |
+----[SHA256]-----+
[root@node1 ~]# ls /root/.ssh 查看密钥文件
id_rsa id_rsa.pub
[root@node1 ~]# ssh-copy-id redhat@192.168.6.128 #定位node1端上传公钥
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"
The authenticity of host '192.168.6.128 (192.168.6.128)' can't be established.
ED25519 key fingerprint is SHA256:I5LOcmDgbIBATAxUDqV88JV7xap5wjMSPo4DSfUd3A0.
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
redhat@192.168.6.128's password:
Connection closed by 192.168.6.128 port 22[root@node1 ~]# ssh redhat@192.168.6.128 验证