centos7 ssh 免密登陆

先生成密钥

ssh-keygen -t rsa

将公钥填入authorized_keys文件,再设置文件权限,

cat id_rsa.pub >> authorized_keys
chmod 600 authorized_keys
chmod 700 ~/.ssh

修改

vim /etc/ssh/sshd_config
RSAAuthentication yes
PubkeyAuthentication yes

最后重启

systemctl restart sshd

如果要禁止密码登陆,修改sshd_config文件

PasswordAuthentication no

 用私钥登陆ssh即可

猜你喜欢

转载自www.cnblogs.com/rirtue/p/10877071.html