无法使用正确的密码通过远程 SSH 登录

无法使用正确的密码通过远程 SSH 登录

在 cPanel 服务器上,昨天 SSH 可以正常工作,但我突然无法使用 SSH 登录。我收到“拒绝访问”的提示。

我检查了 中是否启用了密码登录,/etc/ssh/sshd_config结果确实如此。我尝试通过 KVM 以 root 身份登录,然后通过 SSH 连接到localhost,成功了。

我尝试了多个帐户,甚至创建了一个新帐户,但都不起作用,而且我确定密码是正确的,因为我已经多次重置它们,甚至将它们复制粘贴到 Putty 中,更不用说它们通过 KVM 工作了。

我不知道发生了什么事会导致这种情况在一夜之间发生改变。

我还检查了sshd_config允许AllowUser您限制对特定 IP 的访问的指令,但是没有任何指令。

还有一点,我刚刚在我的手机的 4G 上检查过,它可以在那里运行,只是不能在我的 DSL 上运行。

过去,我的 DSL 连接速度很慢,而且与服务器的连接也不稳定。即使转移到其他国家/地区的其他主机后也是如此。那时,我尝试的所有其他网站都运行正常。不确定是否相关。

ssh -v这是使用 Git for Windows SSH的输出。

OpenSSH_6.6.1, OpenSSL 1.0.1i 6 Aug 2014
debug1: Connecting to <host> [<IP>] port 22.
debug1: Connection established.
debug1: identity file /.ssh/id_rsa type -1
debug1: identity file /.ssh/id_rsa-cert type -1
debug1: identity file /.ssh/id_dsa type -1
debug1: identity file /.ssh/id_dsa-cert type -1
debug1: identity file /.ssh/id_ecdsa type -1
debug1: identity file /.ssh/id_ecdsa-cert type -1
debug1: identity file /.ssh/id_ed25519 type -1
debug1: identity file /.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.6.1
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.3
debug1: match: OpenSSH_5.3 pat OpenSSH_5* compat 0x0c000000
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5 none
debug1: kex: client->server aes128-ctr hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<3072<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Server host key: RSA <key>
The authenticity of host '<host> (<IP>)' can't be established.
RSA key fingerprint is <key>.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '<host>,<IP>' (RSA) to the list of known hosts.
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
debug1: Next authentication method: publickey
debug1: Trying private key: /.ssh/id_rsa
debug1: Trying private key: /.ssh/id_dsa
debug1: Trying private key: /.ssh/id_ecdsa
debug1: Trying private key: /.ssh/id_ed25519
debug1: Next authentication method: password
<user>@<host>'s password:
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
Permission denied, please try again.
<user>@<host>'s password:

答案1

过去,我的 DSL 连接速度很慢,而且与服务器的连接也不稳定。即使转移到其他国家/地区的其他主机后也是如此。那时,我尝试的所有其他网站都运行正常。不确定是否相关。

根据ssh -v您所显示的调试输出 - 以及我认为相关的上述评论 - 我建议sshd_config像这样调整您的服务器;请注意,我喜欢使用,nano但请随意使用您喜欢的任何文本编辑器。

ssh_config首先,像这样打开文件:

sudo nano /etc/ssh/sshd_config

应该有一个名为的配置区域GSSAPI options,如下所示:

# GSSAPI options
#GSSAPIAuthentication no
#GSSAPICleanupCredentials yes

将其更改为取消注释以下行GSSAPIAuthentication no

# GSSAPI options
GSSAPIAuthentication no
#GSSAPICleanupCredentials yes

最后,保存该文件并重新启动 SSH 服务器守护程序,如下所示。要在基于 RedHat/CentOS 的系统上重新启动 SSH,请执行以下操作:

sudo service sshd restart

要在基于 Debian/Ubuntu 的系统上重新启动 SSH,请执行以下操作:

sudo service ssh restart

现在尝试再次登录。我仍然建议ssh -v出于调试目的,但我相信这会让事情变得清晰。

答案2

我重新安装了该openssh-server软件包,目前看来它已经起作用了。文件sshd_config与上次相比没有变化,所以这很奇怪。

答案3

就我而言,sshd_config 中的第 73 行是罪魁祸首。在其他地方找不到这个解决方案,只能碰碰运气了。要么注释掉它(要么将其改为“yes”):

KbdInteractiveAuthentication no

或许这会禁止登录远程服务器时的键盘交互。

相关内容