当我尝试 ssh 连接到远程计算机时出现以下错误:
Received disconnect from RemoteIPAddress: 2: Too many authentication failures for UserNameA
但是直到最近,这个功能才正常工作。我要求我输入密码,然后我就可以登录了。似乎我搞砸了我的 ssh 配置。也许可以通过以下方法这网站建议使用一些 ssh 代理......
有人知道如何修复我的 ssh 配置到正常设置吗?这是ssh -v UserNameA@RemoteIPAddress
ssh -v UserNameA@RemoteHostName
OpenSSH_6.6.1, OpenSSL 1.0.1f 6 Jan 2014
debug1: Reading configuration data /home/myUserName/.ssh/config
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to RemoteHostName [RemoteIPAddress] port 22.
debug1: Connection established.
debug1: identity file /home/myUserName/.ssh/id_rsa type 1
debug1: identity file /home/myUserName/.ssh/id_rsa-cert type -1
debug1: identity file /home/myUserName/.ssh/id_dsa type -1
debug1: identity file /home/myUserName/.ssh/id_dsa-cert type -1
debug1: identity file /home/myUserName/.ssh/id_ecdsa type -1
debug1: identity file /home/myUserName/.ssh/id_ecdsa-cert type -1
debug1: identity file /home/myUserName/.ssh/id_ed25519 type -1
debug1: identity file /home/myUserName/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.6.1p1 Ubuntu-2ubuntu2
debug1: Remote protocol version 2.0, remote software version OpenSSH_6.6.1p1 Ubuntu-2ubuntu2
debug1: match: OpenSSH_6.6.1p1 Ubuntu-2ubuntu2 pat OpenSSH_6.6.1* compat 0x04000000
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr [email protected] none
debug1: kex: client->server aes128-ctr [email protected] none
debug1: sending SSH2_MSG_KEX_ECDH_INIT
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ECDSA 21:65:ef:ce:ad:da:e1:12:80:25:28:1b:r5:6b:ef:a7
debug1: Host 'RemoteHostName' is known and matches the ECDSA host key.
debug1: Found key in /home/myUserName/.ssh/known_hosts:21
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: /home/myUserName/.ssh/id_rsa
debug1: Authentications that can continue: publickey,password
debug1: Offering RSA public key: myUserName@cvg04
debug1: Authentications that can continue: publickey,password
debug1: Offering RSA public key: myUserName@cvg04
debug1: Authentications that can continue: publickey,password
debug1: Offering RSA public key: myUserName@cvg04
debug1: Authentications that can continue: publickey,password
debug1: Offering RSA public key: myUserName@cvg04
debug1: Authentications that can continue: publickey,password
debug1: Offering RSA public key: myUserName@cvg04
Received disconnect from RemoteIPAddress: 2: Too many authentication failures for UserNameA
我尝试操作/etc/ssh/sshd_config
并调用sudo /etc/init.d/ssh reload
:
RSAAuthentication no
PubkeyAuthentication no
[...]
PasswordAuthentication yes
但它没有帮助:-/
答案1
如果您知道您不想使用公钥认证,您可以告诉您的客户端:
ssh -oPubkeyAuthentication=no UserNameA@RemoteHostName
或~/.ssh/config
使用
Host RemoteHostName
PubkeyAuthentication no
如果您知道要使用哪个键,您可以执行类似的操作:
ssh -i /path/to/rsa.key UserNameA@RemoteHostName
或~/.ssh/config
:
Host RemoteHostName
IdentityFile /path/to/rsa.key
如果您弄乱了其他东西,从您的问题中就看不清楚。
答案2
我从您的帖子中了解到,您以前使用密码验证通过 ssh 连接到服务器,但后来您将其更改为使用公钥登录。可以证明您错误配置了 ssh 服务器/客户端。
假设您可以访问 ssh 以外的服务器(可能是控制台),一个肮脏的快速解决方案是卸载(清除)ssh 服务器并重新安装它。
apt-get purge openssh-server ; apt-get install openssh-server
如果您认为问题出在客户端(您的机器),请重新安装 openssh 客户端并确保删除所有以前的 ssh 密钥和配置文件。
您是否尝试过使用另一台电脑通过 ssh 连接到您的服务器?