Centos7多台服务器免密登录

准备四台服务器:

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\]-----+ ![](https://file.jishuzhan.net/article/1690644807023595521/51db1a42b44c41409f5d652fd63766b8.png) **生成的公钥和私钥存储在/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 ![](https://file.jishuzhan.net/article/1690644807023595521/c648685373e843fd94720a8aed1dcea8.png) *** ** * ** *** (二) 节点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/ ![](https://file.jishuzhan.net/article/1690644807023595521/45529a8e5e4b4af59043376c2d7f9307.png) (三)验证 \[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\ mtu 1500 inet **192.168.1.101** netmask 255.255.255.128 broadcast 192.168.1.127 inet6 2409:8a00:79a4:9290:20c:29ff:feb7:c791 prefixlen 64 scopeid 0x0\ inet6 fe80::20c:29ff:feb7:c791 prefixlen 64 scopeid 0x20\ ether 00:0c:29:b7:c7:91 txqueuelen 1000 (Ethernet) RX packets 5059 bytes 391546 (382.3 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 2130 bytes 223968 (218.7 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 lo: flags=73\ mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 inet6 ::1 prefixlen 128 scopeid 0x10\ loop txqueuelen 1000 (Local Loopback) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 *** ** * ** *** 从docker1再次回到节点docker0 \[root@www \~\]# exit 登出 **Connection to 192.168.1.101 closed** . \[root@www \~\]# **ifconfig** ens32: flags=4163\ mtu 1500 inet **192.168.1.100** netmask 255.255.255.128 broadcast 192.168.1.127 inet6 2409:8a00:79a4:9290:c586:1ca9:1eb9:7cd1 prefixlen 64 scopeid 0x0\ inet6 fe80::41b2:5b2a:c067:9234 prefixlen 64 scopeid 0x20\ ether 00:0c:29:df:cc:db txqueuelen 1000 (Ethernet) RX packets 6262 bytes 500539 (488.8 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 3157 bytes 362677 (354.1 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 lo: flags=73\ mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 inet6 ::1 prefixlen 128 scopeid 0x10\ loop txqueuelen 1000 (Local Loopback) RX packets 313 bytes 57926 (56.5 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 313 bytes 57926 (56.5 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 至此,多台服务器之间可以免密登录,相互拷贝

相关推荐
测试员周周3 小时前
【Appium 系列】第16节-WebView-H5上下文切换 — 混合应用的自动化难点
运维·开发语言·人工智能·功能测试·appium·自动化·测试用例
小辰记事本5 小时前
从零读懂RoCEv2数据包构造:从WQE到线缆上的完整旅程
服务器·网络·网络协议·rdma
在角落发呆7 小时前
Linux转发配置:解锁网络互联的核心密码
linux·运维·网络
裴东青9 小时前
10-实战:RuoYi-Cloud的自动化发布
运维·ci/cd·自动化
江公望9 小时前
Ubuntu htop命令,10分钟讲清楚
linux·服务器
哎呦,帅小伙哦9 小时前
Linux 时间:从原子钟到 clock_gettime 的每一面
linux·运维·服务器
sxgzzn9 小时前
新能源场站数智化转型:基于数字孪生与AI的智慧运维管理平台解析
大数据·运维·人工智能
张小姐的猫9 小时前
【Linux】多线程 —— 线程互斥
linux·运维·服务器·c++
CodeMartain10 小时前
Dify Windows 原生部署(无 Docker、纯本地)
运维·docker·容器
xxx1x1x10 小时前
极客向:DLL/运行库故障的底层逻辑与自动化修复方案
运维·自动化·dll文件·dll·dll修复·dll缺失·dll一键修复