所處環境: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