centos7.9 设置服务器密钥登陆

1、Xshell生成公钥和私钥

2、将公钥导入到authorized_keys

cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys

3、修改SSH的配置文件/etc/ssh/sshd_config

vi /etc/ssh/sshd_config

然后“/内容”搜索到以下配置文件并进行修改

 PubkeyAuthentication yes    #启用公告密钥配对认证方式 
 AuthorizedKeysFile  %h/.ssh/authorized_keys    #设定PublicKey文件路径
 RSAAuthentication yes  #允许RSA密钥
 PasswordAuthentication no #禁止密码验证登录,如果启用的话,RSA认证登录就没有意义了
 #禁用root账户登录,非必要,但为了安全性,请配置
 PermitRootLogin no

4、修改完ssh配置文件后,重启服务

systemctl restart sshd.service
posted @ 2022-03-04 10:11  Ephemeralx  阅读(479)  评论(0编辑  收藏  举报