Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I've done several attempts to establish SSH-connecton for user root@host using putty terminal. While doing so I specified wrong credentials several times and after that I've specified them correctly, and then after the credentials were accepted the ssh session breaks with

"Server unexpectedly closed network connection".

This error is reported by putty terminal. When trying to ssh root@localhost from the local console - it works fine. It also works fine when I ssh otheruser@host from other host. So network connectivity issues are not guilty. The only error I am thinking of is: "Too many Authentication Failures for user root" although putty reported a different error.

The question is: how to recover from this error condition and let putty login again? Restarting sshd seems to not help

share|improve this question

8 Answers 8

up vote 7 down vote accepted

Are you sure that root login to ssh is allowed?

Check sshd_config and verify that root login is permitted. sshd will need to be restarted if the setting changes.

share|improve this answer

"Too many Authentication Failures for user root" means that Your SSH server's MaxAuthTries limit was exceeded. It happens so that Your client is trying to authenticate with all possible keys stored in /home/USER/.ssh/ .

This situation can be solved by these ways:

  1. ssh -i /path/to/id_rsa root@host
  2. Specify Host/IdentityFile pair in /home/USER/.ssh/config .
    • Host host
    • IdentityFile /home/USER/.ssh/id_rsa
    • Host host2
    • IdentityFile /home/USER/.ssh/id_rsa2
  3. Increase MaxAuthTries value on the SSH server in /etc/ssh/sshd_config (not recommended).
share|improve this answer

On the remote machine open /etc/sshd_config and change value

MaxAuthTries 30

This is typical problem when You have installed multiple keys or open multiple connections. Server checking step by step each key and if MaxAuthTries is setup on 3 then after first 3`rd tries will disconnect You. Typical ssh security.

I suggest You to use verbose mode during connection to remote machine to analyze problem.

ssh -v -p port_number user@servername

Guessing like most poeple on this forum do is WRONG and its wasting of time. First try to analyze problem, collect informations and then ask.

Have fun.

share|improve this answer
    
In my specific case, the problem was that I was logged in with agent forwarding, trying to run a script that used it's own SSH identity. When I ran it with agent forwarding, it was too many identities before it tried it's own. So I set up the script to throw away the agent environment and that cleared it up. I also could have increased the MaxAuthTries, but I didn't need to in this case. –  Sean Reifschneider Nov 21 '10 at 0:04
    
Thanks. -v showed my ssh client trying to use multiple keys (I have quite a few now). I cleaned them from the agent with ssh-add -D –  joeytwiddle Jul 14 at 7:54

I would recommend you, as Anon above posted, use another user to gain ssh access then use the su command to gain root access...

PermitRootLogin can be set to no in th /etc/ssh/sshd_config

hope that helps

share|improve this answer

This is bad practice. Just have a regular user on the remote box and connect through ssh using it, then gain root access using su/sudo.

share|improve this answer

If you get the following SSH Error:

$ Received disconnect from host: 2: Too many authentication failures for root

This could happen if you have (default on my system) five or more DSA/RSA identity files stored in your .ssh directory. In this case if the '-i' option isn't specified at the command line the ssh client will first attempt to login using each identity (private key) and next prompt for password authentication. However, sshd drops the connection after five bad login attempts (again default may vary). So if you have a number of private keys in your .ssh directory you could disable "Public Key Authentication" at the command line using the '-o' optional argument.

For example:

$ ssh -o PubkeyAuthentication=no root@host

share|improve this answer

I fixed this issue on my Mac by:

  1. setting the root password with "sudo passwd root" then
  2. editing and saving the ssh config file with "nano /etc/ssh_config" and
  3. changing the RSAAuthentication to "no" rather than yes.
share|improve this answer

had this problem with my appletv

in the end sudo'ing with ssh worked.

share|improve this answer
    
Can you add any more details to this? –  slm Jan 7 '13 at 6:14

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.