0

When I try to ssh to a remote computer I get the following error:

Received disconnect from RemoteIPAddress: 2: Too many authentication failures for UserNameA

However until recently this used to work fine. I asked me for a password and I could login. It seems like I messed up my ssh configuration. Maybe by following this website which recommended using some ssh - agent...

Does anyone know how to repair my ssh configuration to the normal setting. This is the output of 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

I tried manipulating /etc/ssh/sshd_config and calling sudo /etc/init.d/ssh reload:

RSAAuthentication no
PubkeyAuthentication no
[...]
PasswordAuthentication yes

But it didn't help :-/

2 Answers 2

1

If you know that you don't want to use public key authentication, you can tell it to your client:

ssh -oPubkeyAuthentication=no UserNameA@RemoteHostName

or in ~/.ssh/config using

Host RemoteHostName
  PubkeyAuthentication no

If you know what key you want to use, you can do the similar:

ssh -i /path/to/rsa.key UserNameA@RemoteHostName

or in ~/.ssh/config:

Host RemoteHostName
  IdentityFile /path/to/rsa.key

If you messed something else, it is not clear from your question.

2
  • I tried all the above. They are working, but it is still annoying, because in my default configuration, I didn't have to write a .ssh/config file. It is quite annoying to write these files since I also use several logins for the same computer and I want them to use a password in case I connect as a normal user and pubkey in case I connect as an admin. Do you know how to change the default authentication to password? Maybe it's rather a problem of the ssh agent which matches some wrong ssh key instead of asking for the password...
    – mcExchange
    May 13, 2016 at 12:35
  • It is enough to write config once. If you don't use ssh-agent, just remove the connection (SSH_AUTH_SOCK="") and it will stop offering the keys from it.
    – Jakuje
    May 13, 2016 at 13:25
1

What i understood from your post is that you used to ssh to your server using password authentication but you then changed this so you can login with Public Key. Provably you miss-configured your ssh-server/client.

Assuming you have access to the server other than ssh (console maybe), a dirty , quick solution would be to uninstall (purge) the ssh server and reinstall it.

apt-get purge openssh-server ; apt-get install openssh-server

If you think the problem is on the client side (your machine) reinstall your openssh client and make sure you remove any previous ssh keys and configuration files.

Have you tried to ssh to your server using another PC?

8
  • I guess the problem is rather with my computer. Since everything was working fine in the past, until I started creating some RSA-keys and using this ssh-agent which I assume is messing with my configuration but I'm not sure how to switch it off
    – mcExchange
    May 13, 2016 at 12:44
  • @mcExchange I have updated my answer above. Why not try to re-install your ssh client on your computer? Make sure you will remove any config files and previously generated ssh keys. This will produce a clean config file and new rsa-keys. Also, try to ssh from another computer in order to clarify your thinking.
    – giomanda
    May 13, 2016 at 12:47
  • Removing all files from ~/.ssh brought me closer to the problem. Apparantly there is one key, which I shared accross my remote computers which keeps on invoking the wrong RSA key on my computer and consequently fails on authentication.... Do you know how to set password authentication as default instead of rsa-key ?
    – mcExchange
    May 13, 2016 at 13:17
  • @mcExchange I am not sure i understand what you mean with your latest comment. Who is invoking the wrong RSA key? Unless you have strictly configured your ssh server to use only public key authentication, then, even if the wrong key used on your client machine, it should fall-back to password authentication and prompt you for a password.
    – giomanda
    May 13, 2016 at 13:25
  • Yes falling back to password authentication is what I would also expect but instead I'm getting Too many authentication failures for UserNameA ... Do you have a computer where you connect with both password and key, depending on which username you are trying to log in with?
    – mcExchange
    May 13, 2016 at 13:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .