1、四台主机:
cat /etc/hosts
xxx.xxx.xxx.169 bdai01
xxx.xxx.xxx.170 bdai02
xxx.xxx.xxx.171 bdai03
xxx.xxx.xxx.172 bdai04
2、主机bdai01,bdai02,bdai03,bdai04都需要执行一下步骤,如果之前做过免密,后来改密码了,最好把原来的.ssh目录删掉:
rm -rf /bdai/.ssh(四台都需要删掉,删掉以后在执行以下语句)
ssh-keygen -t rsa
cat /bdai/.ssh/id_rsa.pub >> /bdai/.ssh/authorized_keys
chmod 700 /bdai/
chmod 700 /bdai/.ssh
chmod 644 /bdai/.ssh/authorized_keys
chmod 600 /bdai/.ssh/id_rsa
3、在在四台主机(bdai01,bdai02,bdai03,bdai04)执行以下语句
ssh-copy-id -i /bdai/.ssh/id_rsa.pub bdai@bdai01
ssh-copy-id -i /bdai/.ssh/id_rsa.pub bdai@bdai02
ssh-copy-id -i /bdai/.ssh/id_rsa.pub bdai@bdai03
ssh-copy-id -i /bdai/.ssh/id_rsa.pub bdai@bdai04
输入yes,然后输入对端密码,就可以成功了。
bdai@ithemzhdpbd01[/bdai/.ssh]$ ssh-copy-id -i /bdai/.ssh/id_rsa.pub bdai@bdai04
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/bdai/.ssh/id_rsa.pub"
The authenticity of host 'bdai04 (xxx.xxx.xxx.172)' can't be established.
ECDSA key fingerprint is SHA256:48H4J1jOXyMNLIbu1ECiECKPuBPkiJ2aQkjdFAXgTsU.
ECDSA key fingerprint is MD5:b8:fa:be:10:3b:91:81:e2:04:1c:d5:fc:6c:ac:ac:e6.
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
SISTEMA PRIVADO. UNICAMENTE USUARIOS AUTORIZADOS.
EL USO DE ESTE SISTEMA ES EXCLUSIVO PARA LOS FINES AUTORIZADOS POR
RADIOMOVIL DIPSA S.A DE C.V. Y ESTA SUJETO A SER AUDITADO EN
CUALQUIER MOMENTO.
TODA LA INFORMACION AQUI MANEJADA TIENE CARACTER DE CONFIDENCIAL.
LOS PASSWORD DEBEN SER CAMBIADOS CADA 60 DIAS.
bdai@bdai04's password:
Number of key(s) added: 1
Now try logging into the machine, with: "ssh 'bdai@bdai04'"
and check to make sure that only the key(s) you wanted were added.
bdai@ithemzhdpbd01[/bdai/.ssh]$