跳转到主要内容

Linux集群SSH免密登陆

分类
故障描述

  无

故障分析

  无

处理过程

      Linux集群规模20台,需相互间免密登陆。

      先选择一台主机保存所有主机的密钥,然后将密钥复制到所有主机。

1.登陆每台主机创建ssh.pub:

[root@master-1 ~]# ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
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:Z0rzrrX1DA+Yjw6S9iFnoGQfQc9NVn1PXEXHohC/gno root@jumpserver
The key's randomart image is:
+---[RSA 3072]----+
|      .   +o.. +B|
|     . o +..  o *|
|      . o .... +.|
|       . .  ..  .|
|    o o S + .    |
|   o o * * +     |
|    . B E = +    |
|     . B = = *   |
|        oo= . +  |
+----[SHA256]-----+

 

2. 每台主机执行ssh-copy-id root@master-1复制到Master-1

3.登陆Master-1将密码复制到所有主机:

scp .ssh/authorized_keys root@master-2:/root/ssh.txt

scp .ssh/authorized_keys root@master-3:/root/ssh.txt

scp .ssh/authorized_keys root@node-1:/root/ssh.txt

....

4.登陆每台主机,将ssh.txt追加到.ssh/authorized_keys即可。

cat /root/ssh.txt >> /root/.ssh/authorized_keys

建议/总结

  无