linux中免密登录@2024-03-01

2024-02-29  本文已影响0人  dataHunter
# 各机器创建秘钥
ssh-keygen -t rsa

# 从各个机器汇集公钥到ip1
scp ~/.ssh/id_rsa.pub root@ip1:~/.ssh/2.id.rsa.pub
scp ~/.ssh/id_rsa.pub root@ip1:~/.ssh/3.id.rsa.pub
scp ~/.ssh/id_rsa.pub root@ip1:~/.ssh/4.id.rsa.pub
scp ~/.ssh/id_rsa.pub root@ip1:~/.ssh/5.id.rsa.pub
scp ~/.ssh/id_rsa.pub root@ip1:~/.ssh/6.id.rsa.pub

# 在ip1里生成秘钥认证文件
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
cat ~/.ssh/2.id.rsa.pub >> ~/.ssh/authorized_keys
cat ~/.ssh/3.id.rsa.pub >> ~/.ssh/authorized_keys
cat ~/.ssh/4.id.rsa.pub >> ~/.ssh/authorized_keys
cat ~/.ssh/5.id.rsa.pub >> ~/.ssh/authorized_keys
cat ~/.ssh/6.id.rsa.pub >> ~/.ssh/authorized_keys

# 向集群机器分发认证文件
scp ~/.ssh/authorized_keys root@ip2:~/.ssh/
scp ~/.ssh/authorized_keys root@ip3:~/.ssh/
scp ~/.ssh/authorized_keys root@ip4:~/.ssh/
scp ~/.ssh/authorized_keys root@ip5:~/.ssh/
scp ~/.ssh/authorized_keys root@ip6:~/.ssh/

上一篇下一篇

猜你喜欢

热点阅读