Authentication 为什么不允许密码身份验证?

Authentication 为什么不允许密码身份验证?,authentication,ssh,passwords,Authentication,Ssh,Passwords,我的ssh现在似乎只接受公钥身份验证。即使我确信在我的/etc/ssh/ssh\u配置中“PasswordAuthentication”是肯定的。 这是我的ssh日志。我想知道为什么我的ssh中不允许密码身份验证?注意:我可以通过在命令行中添加“-o PubkeyAuthentication=no”来强制ssh使用密码身份验证 markz@markz-hp6200:~$ ssh -l lab 10.19.170.114 -v OpenSSH_5.9p1 Debian-5ubuntu1, Open

我的ssh现在似乎只接受公钥身份验证。即使我确信在我的/etc/ssh/ssh\u配置中“PasswordAuthentication”是肯定的。 这是我的ssh日志。我想知道为什么我的ssh中不允许密码身份验证?注意:我可以通过在命令行中添加“-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

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

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

主人* PubkeyAuthentication=否


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

您的
~/.ssh
中的密钥太多了

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


移动或删除一些未使用的密钥,使“
ssh add-l
”中的密钥少于5个。

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

例如,您在本地覆盖了/etc/hosts中的主机名,给出了一个与远程SSH服务器的实际主机名不同的别名

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


希望这有帮助。

谢谢。是的,我在~/.ssh目录中有一些公钥,但据我所知,ssh不应该使用它们来尝试进行身份验证,id_rsa.pub除外。但无论如何,我认为你的建议是对的,我会试试看。通过添加“Host*PubkeyAuthentication=no”,我可以登录到需要密码验证的服务器,但不能登录到需要pubkey的服务器(好的,我想出来了。需要为每个需要pubkey身份验证的站点添加“PubkeyAuthentication yes”。顺便说一句,您也可以在~/.ssh/config中使用
Host
指令执行此操作(无法推断您是否执行了此操作,或者是否每次都将其作为选项添加到命令行)。