多主机免密互信

简介: 多主机免密互信
# 准备三台机器
192.168.57.131
192.168.57.132
192.168.57.133
[root@localhost ~]# pwd    # 三台机器都检查一下,都没有生成过公钥
/root
[root@localhost ~]# ls -a
.   anaconda-ks.cfg  .bash_logout   .bashrc  .mysql_history  .tcshrc
..  .bash_history    .bash_profile  .cshrc   .pki            .viminfo
[root@localhost ~]# ssh-keygen    # 三台机器都需要创建各自的公钥
[root@localhost ~]# ssh-copy-id 192.168.57.131   # 三台机器都需要给自己copy-id,生成authorized_keys文件
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"
The authenticity of host '192.168.57.131 (192.168.57.131)' can't be established.
ECDSA key fingerprint is SHA256:hZ85f0Jqzh98Wv8A+RWjMt/aFLffN5+8Fm0pif0MJa0.
ECDSA key fingerprint is MD5:fd:9b:5f:c4:5f:31:36:78:26:60:96:f3:8e:f9:df:ab.
Are you sure you want to continue connecting (yes/no)? 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
root@192.168.57.131's password:
Number of key(s) added: 1
Now try logging into the machine, with:   "ssh '192.168.57.131'"
and check to make sure that only the key(s) you wanted were added.
[root@localhost ~]# ls .ssh/
authorized_keys  id_rsa  id_rsa.pub  known_hosts
[root@localhost ~]# ssh-copy-id 192.168.57.131   # 132、133两台机器,将自己的authorized_keys追加到130机器内
[root@localhost ~]# cat .ssh/authorized_keys   # 这个时候,130机器内,有三个公钥了
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCYOGBV1a9+127y6u3JVruAcQE7/eYfAbkLsmhHSmNWcBm1AZ4AHffoPd7rSg9BdferVSOS4ZBYokxTUU1rF3YXEcFZezSQ47kD/tnFT0YiCqJTRv53SsaJBLY5Ax50ViI+WXUEwpDxH3cWsjCcm9U+2uD/fK54MsGFxmxpensF2jFjWj3nugF4jk5XFD9syztu6niCXmuZUTaAv5QFhTbOUK2xmePhjw624hEaU84NOtCMyBdIxKzbjtlZsbGsk8F+IYlfY0WPuAK9sPN8JXgEWLQdfemopTjExAoQowWe7YrG03WcU8OmevgqutMosAeGwv0yKK2dd1NV7DxJlTRh root@localhost.localdomain
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDGymP3n7Z+f9g9tvUO+7bdNTB+RmJ8GQ6fmtgETfbQQ4LQ6qi2RBqXVRTjKiv70eGs8tNRyodqCP/iPue8Z28cdm+jOUy5S7kuN+X3XeG6OaHBqP+ea3pxh/LYxq1SsQQ/2sbFj2RAlj3dPKeWLGspdchs2bWX/MYgGLftorZlbZ/NbiWmw2iOFZownuAjFo0Cy5Tw4QjgWkeIdz0obMA+vDQYfw4kE6MKiJZ9b1v1MFm+XxQ3PcxseJhUKDH0I+ea/eBkK3be60pb7AXEh1tFw95nuprLuE7/qQMc2huzQGedAZIFq8IrnVHOV+vYgeF77OdcP+C3bKLENotVG0Wd root@localhost
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDbN7NfZ5wfmOrS+ADiFBEJbBIsZKOyA1EXHCaMwwQVBWN7OlP5vXfSRV6VJrDsClux76+QN8ui1pdMN6PTesflZ1bFHdhzCsd5P74IlwrtY0+9IbD5CjZNnYvzkK+/P/fBZ5fE44lpBgz4jXWHjChKamIjf4i2H0QZk7mAGg+HkOZE2BU1U89dNfOTyuRHFEoHCGqVRu3lfrIHBrSIL0Rz8ZEdSDU+inncuCsOyc4hLljRpw9BVdV9LZzGZivKRz+dNhratY/qLqn6PXY1D7H4RDVs71dQ7jxU+0VxbHmxwxTFfw+mQ8aDFfilQF9nFXTlWQHtM1Ai8Vhf+JwvHzL3 root@localhost
[root@localhost ~]# scp .ssh/authorized_keys 192.168.57.132:/root/.ssh/
[root@localhost ~]# scp .ssh/authorized_keys 192.168.57.133:/root/.ssh/
[root@localhost ~]# ssh 192.168.57.132     # 测试成功,只需要一个yes,无需密码
The authenticity of host '192.168.57.132 (192.168.57.132)' can't be established.
ECDSA key fingerprint is SHA256:hZ85f0Jqzh98Wv8A+RWjMt/aFLffN5+8Fm0pif0MJa0.
ECDSA key fingerprint is MD5:fd:9b:5f:c4:5f:31:36:78:26:60:96:f3:8e:f9:df:ab.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.57.132' (ECDSA) to the list of known hosts.
Last login: Fri Jul 10 20:30:24 2020 from 192.168.57.131
目录
相关文章
|
7月前
|
消息中间件 安全 Unix
SSH配置多台服务器之间的免密登陆以及登陆别名
SSH配置多台服务器之间的免密登陆以及登陆别名
202 1
|
4月前
|
网络安全
[ansible]建立ssh互信
[ansible]建立ssh互信
|
Shell Linux 网络安全
ssh 主机之间免密配置脚本
ssh 主机之间免密配置脚本
103 0
|
运维 网络安全 数据安全/隐私保护
华为交换机如何配置SSH远程登录,一分钟秒学会
华为交换机如何配置SSH远程登录,一分钟秒学会
4152 0
华为交换机如何配置SSH远程登录,一分钟秒学会
|
网络协议 安全 Linux
ssh端口转发(跳板机)详解
如果在工作环境中,被防火墙限制了一些网络端口的使用,但是允许SSH的连接,也能够将通过ssh端口转发来进行通讯。
4895 1
ssh端口转发(跳板机)详解
|
测试技术 Linux 网络安全
Linux系统配置SSH免密登录(多主机互通)
Linux系统配置SSH免密登录(多主机互通) 本文测试环境: Linux系统镜像:CentOS-7-x86_64-DVD-1804.iso 虚拟机版本:VMware-workstation-full-12.
4297 0
|
安全 Ubuntu Shell
如何使用端口碰撞为SSH登录确保安全?
如何使用端口碰撞为SSH登录确保安全?
如何使用端口碰撞为SSH登录确保安全?
|
Shell 网络安全 数据安全/隐私保护
使用 ssh-agent,实现多台机器 ssh 免密码登陆
使用 ssh-agent,实现多台机器 ssh 免密码登陆
659 0
|
网络安全 数据安全/隐私保护