记一次设置密钥登陆centos7所遇问题

所处环境:centos7
连接工具:xshell
1.上传公钥
2.修改公钥名称
mv id_rsa_2048.pub authorized_keys
3.修改ssh配置文件
[root@localhost .ssh]# vim /etc/ssh/sshd_config
Protocol 2 启用ssh协议V2版本
PasswordAuthentication no 禁止密码登录认证
AuthorizedKeysFile .ssh/authorized_keys 打开公钥认证的功能,注意路径与名称
PubkeyAuthentication yes 启用公钥认证功能
4.让ssh配置文件生效
[root@localhost .ssh]#systemctl restart sshd


xshell报错:所选用户密钥未在远程主机注册,请在试一次
1、检查用户名是否填写正确
2、检查服务器的selinux和防火墙是否正确配置

cat /var/log/secure报错:POSSIBLE BREAK-IN ATTEMPT
可以将/etc/ssh/ssh_config配置文件中的
GSSAPIAuthentication yes
改为:
GSSAPIAuthentication no

猜你喜欢

转载自blog.51cto.com/13289255/2401786