2013-03-26 89 views
5

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

[email protected]:~$ 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: [email protected] 
debug1: Authentications that can continue: publickey,password 
debug1: Offering RSA public key: [email protected] 
debug1: Authentications that can continue: publickey,password 
debug1: Offering RSA public key: [email protected] 
debug1: Authentications that can continue: publickey,password 
debug1: Offering RSA public key: [email protected] 
debug1: Authentications that can continue: publickey,password 
debug1: Offering RSA public key: [email protected] 
debug1: Authentications that can continue: publickey,password 
debug1: Offering RSA public key: [email protected] 
Received disconnect from 10.19.170.114: 2: Too many authentication failures for lab 

回答

3

SSH客户端没有改变,甚至尝试密码身份验证,因为所有的认证尝试用你的公钥。

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

主机* Pubkey验证=无

~/.ssh/config或实际在服务器端增加一个公共密钥~/.ssh/authorized_keys使用公共密钥认证。

+0

谢谢。是的,我的〜/ .ssh目录中有一些公钥,但根据我的理解,ssh不应该使用它们来尝试验证,除了id_rsa.pub。但无论如何,我认为你的建议是正确的,我会尝试。 – 2013-03-28 09:50:19

+0

通过添加“Host * PubkeyAuthentication = no”,我可以登录到需要密码验证的服务器,但无法登录需要pubkey的服务器。 :( – 2013-03-29 03:53:54

+0

好吧,我想通了,需要为需要pubkey认证的每个站点添加“PubkeyAuthentication yes”。 – 2013-03-29 04:02:13

4

恐怕您的~/.ssh中有太多按键可用。

ssh似乎试图使用第一个可用的每个密钥,但目标机器只接受5个身份验证请求,所以没有机会尝试密码身份验证。

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

1

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

因此对于例如您已在本地重写了您的/ etc/hosts中的主机名,并给出与实际主机名与远程SSH服务器不同的别名。

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

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

希望这会有所帮助。

+0

好的..尽管我的问题不是这个,谢谢。 – 2014-01-05 08:13:07