服务器之间的ssh无密码连接;
准备机器
主机名 | ip |
---|---|
es1 |
192.168.24.140 |
es2 |
192.168.24.128 |
es3 |
192.168.24.139 |
生成秘钥
ssh-keygen -t rsa
传输公钥
cd .ssh/
cat id_rsa.pub >>authorized_keys
chmod 600 authorized_keys
scp -rp .ssh 192.168.24.128:~
scp -rp .ssh 192.168.24.139:~
hosts解析
cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.24.140 es1
192.168.24.128 es3
192.168.24.139 es2
测试
[root@es1 .ssh]# ssh es2
Last login: Thu Feb 4 15:15:59 2021 from es1