我的ssh似乎现在只接受公钥认证。即使我确定/ etc / ssh / ssh_config中的“PasswordAuthentication”是肯定的。 这是我的ssh日志。我想知道为什么在我的ssh中不允许密码验证? P.S:我可以通过在命令行中添加“-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
答案 0 :(得分:4)
我担心您~/.ssh
中的密钥太多了。
ssh
似乎首先尝试使用每个可用密钥,但目标计算机只接受5个身份验证请求,因此没有机会尝试进行密码身份验证。
移动或移除一些未使用的密钥,以便“ssh-add -l
”中的密钥少于5个。
答案 1 :(得分:3)
SSH客户端甚至没有更改密码验证,因为所有验证尝试都用于您的公钥。
删除未使用的公钥,添加类似
的内容主持人* Pubkey验证=无
到~/.ssh/config
或实际使用公钥验证,方法是在服务器端向~/.ssh/authorized_keys
添加公钥。
答案 2 :(得分:1)
我还发现,如果您没有设置与服务器报告本身相同的主机名,则会弹出此错误,即使您的帐户有效并且正确设置了ssh公钥的权限。
因此,例如您已在本地重写/ etc / hosts中的主机名,并提供与远程SSH服务器的实际主机名不同的别名。
XX.XX.YY.YY host.correct.domain hostalias
如果您尝试使用主机名作为 hostalias 进行ssh,则远程SSH服务器会拒绝公钥身份验证,因为其主机名为 host.correct.domain 。这种情况发生在OpenSSH v4.3服务器版本上。
希望这有帮助。