CentOS 7.6出现SSH登录失败的解决方法

Posted zhangyangdev

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了CentOS 7.6出现SSH登录失败的解决方法相关的知识,希望对你有一定的参考价值。

CentOS 7.6出现SSH登录失败的解决方案

问题重现:

iterm登录

ssh vagrant@192.168.10.10
The authenticity of host '192.168.10.10 (192.168.10.10)' can't be established.
ECDSA key fingerprint is SHA256:8nyfIaEq9jMHfb9aQIlPh5OAGXjjSVGEDiXfMjlD7H8.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.10.10' (ECDSA) to the list of known hosts.
vagrant@192.168.10.10: Permission denied (publickey,gssapi-keyex,gssapi-with-mic).

sshShell登录

>   11:06:29 Connecting to 192.168.10.10 port 22
>   11:06:29 Command: ssh -p 22 vagrant@192.168.10.12
>   11:06:29 Connect to 192.168.10.12:22, with timeout 15.000000
>   11:06:29 Create socket with IPv4 address family
>   11:06:29 Socket is connected successfully
>   11:06:29 Client banner: SSH-2.0-libssh_0.7.5
>   11:06:29 Server banner: SSH-2.0-OpenSSH_7.4
>   11:06:29 Negotiated with server
>   11:06:29 Authentication that can continue: publickey, gssapi-with-mic
>   11:06:29 Disconnected from server

解决办法

1、卸载重新

[root@cent ~]# yum -y remove openssh-server
[root@cent ~]# yum -y install openssh-server

2、生成密钥(可选)

[root@cent ~]# sshd-keygen

3、修改sshd_config配置文件

[root@cent ~]# vim /etc/ssh/sshd_config
# 添加以下内容至文件末尾处 :wq
PubkeyAuthentication yes

4、重新启动sshd

[root@cent ~]# systemctl restart sshd.service

以上是关于CentOS 7.6出现SSH登录失败的解决方法的主要内容,如果未能解决你的问题,请参考以下文章

centos 7.6 设置 SSH 通过密钥登录

CentOS下升级默认的OpenSSH(OpenSSH_5.3p1到OpenSSH_7.6p1)

docker创建centos容器之后ssh登录失败

解决CentOS上SSH登录慢的问题

解决CentOS上SSH登录慢的问题

centos7.x 设置ssh用户多次登录失败锁定 Permission denied, please try again.