Centos7.4 非root用户配置免密不能登陆的问题

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]$

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值