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 至此,多台服务器之间可以免密登录,相互拷贝

相关推荐
RisunJan2 分钟前
Linux命令-lnstat(快速查找文件和目录)
linux·运维·服务器
lihui_cbdd27 分钟前
Slurm 集群内存管理与限制配置
运维·服务器
历程里程碑29 分钟前
Linux 17 程序地址空间
linux·运维·服务器·开发语言·数据结构·笔记·排序算法
CC.GG42 分钟前
【Linux】进程控制(二)----进程程序替换、编写自主Shell命令行解释器(简易版)
linux·服务器·数据库
数研小生1 小时前
Full Analysis of Taobao Item Detail API taobao.item.get
java·服务器·前端
H Journey1 小时前
Linux 下添加用户相关
linux·运维·服务器·添加用户
零基础的修炼2 小时前
Linux网络---网络层
运维·服务器·网络
Trouvaille ~2 小时前
【Linux】线程同步与互斥(三):生产者消费者模型实战
linux·运维·c++·信号量·阻塞队列·生产者消费者模型·环形队列
遇见火星2 小时前
Linux Screen 命令入门指南
linux·运维·服务器
Doro再努力2 小时前
【Linux操作系统06】深入理解权限掩码与粘滞位
linux·运维·服务器