
准备四台服务器:
docker0
docker1
docker2
docker3
在docker0服务器上生成公钥和私钥
root@www \~\]# **ssh-keygen -t rsa**
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Created directory '/root/.ssh'.
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:QX9zBwLmVNRXXbgPLmPZr4515rXXe/GmmpYbc6k3tU8 root@www.yhchange.com
The key's randomart image is:
+---\[RSA 2048\]----+
\| . +++...\*\|
\| . = .o.o\|
\| . o o .o.\|
\| . . oo. \|
\| S + o \|
\| = ooo\|
\| .o++oE\|
\| oOo\*X\|
\| .\*=+BB\|
+----\[SHA256\]-----+

**生成的公钥和私钥存储在/root/.ssh目录下面**
\[root@www \~\]# cd /root/.ssh
\[root@www .ssh\]# ll
总用量 8
-rw-------. 1 root root 1679 8月 13 14:41 id_rsa
-rw-r--r--. 1 root root 403 8月 13 14:41 id_rsa.pub
验证下自己登录自己是否成功:
\[root@www \~\]# ssh-copy-id 192.168.1.100

*** ** * ** ***
(二) 节点docker0上的公钥与私钥拷贝到其他三台机器
scp -pr .ssh/ 192.168.1.101:root/
scp -pr .ssh/ 192.168.1.102:root/
scp -pr .ssh/ 192.168.1.103:root/

(三)验证
\[root@www \~\]# **ssh 192.168.1.101**
Last login: Sun Aug 13 14:33:16 2023 from 192.168.1.5
\[root@www \~\]# **ifconfig**
ens32: flags=4163\