6

我的 ssh 现在似乎只接受公钥认证。即使我确定 /etc/ssh/ssh_config 中的“PasswordAuthentication”是肯定的。这是我的 ssh 日志。我想知道为什么我的 ssh 中不允许密码验证?PS:我可以通过在命令行中添加“-o PubkeyAuthentication=no”来强制 ssh 使用密码认证。

markz@markz-hp6200:~$ ssh -l lab 10.19.170.114 -v
OpenSSH_5.9p1 Debian-5ubuntu1, OpenSSL 1.0.1 14 Mar 2012
debug1: Reading configuration data /home/markz/.ssh/config
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to 10.19.170.114 [10.19.170.114] port 22.
debug1: Connection established.
debug1: identity file /home/markz/.ssh/id_rsa type -1
debug1: identity file /home/markz/.ssh/id_rsa-cert type -1
debug1: identity file /home/markz/.ssh/id_dsa type -1
debug1: identity file /home/markz/.ssh/id_dsa-cert type -1
debug1: identity file /home/markz/.ssh/id_ecdsa type -1
debug1: identity file /home/markz/.ssh/id_ecdsa-cert type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.9p1 Debian-5ubuntu1
debug1: match: OpenSSH_5.9p1 Debian-5ubuntu1 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.9p1 Debian-5ubuntu1
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: sending SSH2_MSG_KEX_ECDH_INIT
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ECDSA d5:c0:00:1b:bf:54:56:a0:c6:68:6f:62:a4:1a:e3:e1
debug1: Host '10.19.170.114' is known and matches the ECDSA host key.
debug1: Found key in /home/markz/.ssh/known_hosts:10
debug1: ssh_ecdsa_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,password
debug1: Next authentication method: publickey
debug1: Offering RSA public key: markz@markz-hp6200
debug1: Authentications that can continue: publickey,password
debug1: Offering RSA public key: markz@markz-hp6200
debug1: Authentications that can continue: publickey,password
debug1: Offering RSA public key: markz@markz-hp6200
debug1: Authentications that can continue: publickey,password
debug1: Offering RSA public key: markz@markz-hp6200
debug1: Authentications that can continue: publickey,password
debug1: Offering RSA public key: markz@markz-desktop
debug1: Authentications that can continue: publickey,password
debug1: Offering RSA public key: markz@markz-desktop
Received disconnect from 10.19.170.114: 2: Too many authentication failures for lab
4

3 回答 3

5

SSH 客户端甚至没有更改尝试密码身份验证,因为所有身份验证尝试都用于您的公钥。

删除未使用的公钥,添加类似

主机 * PubkeyAuthentication=no

通过在服务器端添加公钥来~/.ssh/config或实际使用公钥身份验证。~/.ssh/authorized_keys

于 2013-03-26T07:53:49.943 回答
5

恐怕您的~/.ssh.

ssh似乎首先尝试使用每个可用的密钥,但目标机器将只接受 5 个身份验证请求,因此没有机会尝试密码身份验证。

移动或移除一些未使用的键,使您的“”中的键少于 5 个ssh-add -l

于 2013-10-15T10:56:37.603 回答
1

我还发现,当您没有设置与服务器报告自身相同的主机名时,即使您的帐户有效并且 ssh 公钥的权限设置正确,也会弹出此错误。

因此,例如,您已经在本地覆盖了 /etc/hosts 中的主机名,提供了一个与远程 SSH 服务器的实际主机名不同的别名。

XX.XX.YY.YY   host.correct.domain   hostalias

如果您尝试使用主机名作为hostalias进行 ssh ,远程 SSH 服务器会拒绝公钥身份验证,因为它的主机名是host.correct.domain。这发生在 OpenSSH v4.3 服务器版本上。

希望这可以帮助。

于 2013-12-19T12:16:06.527 回答