Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I can SSH in one direction with no problems:


ssh user@computerA

but the other way:

ssh user@computerB

I get Read from socket failed: Connection reset by peer.

I don't even begin to know where to look to solve this.

Anyone have any clues?

share|improve this question
What's your network configuration ? Is any of the machine behind a firewall/router ? – NorTicUs Oct 23 '12 at 12:54
Both just connected to each other over ethernet cable via a router. They have SSH'd in both directions in the past. – boehj Oct 23 '12 at 13:04
Did you checked both SSH daemons are running? Anything in the logs ? – NorTicUs Oct 23 '12 at 13:07
Good and bad news: I answered my own question. I'll type that out below. Thanks for your help all the same. – boehj Oct 23 '12 at 13:11
  1. start monitoring the server's log file

    tail -f /var/log/auth.log

  2. add -v to get a verbose output at the client end

    ssh user@computerB -v

This might give you more details about the cause. if the rsa and dsa keys are missing on the server, fix them by:

ssh-keygen -t rsa1 -f /etc/ssh/ssh_host_rsa_key
ssh-keygen -t dsa  -f /etc/ssh/ssh_host_dsa_key
share|improve this answer
This worked for me. Though I had to be root to run the following: ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key – StarDust Jan 28 '14 at 0:48
Keys re-generation definitely work. In my case it was changing machine IP address after openssh installed (and keys generated during install). – Alfishe Apr 25 '15 at 2:25
up vote 7 down vote accepted

I re-installed the SSH bits by doing:

sudo apt-get --reinstall install openssh-server openssh-client

This fixed all my problems.

share|improve this answer
Could be a coincidence. That the problem stopped happening at the time you reinstalled ssh isn't an airtight assurance of cause and effect. By the way, which side did you reinstall? Or both? In any case, "this question is unlikely to help future visitors". – Kaz Apr 3 '13 at 8:13

änthräX's method is very helpful. It works for me!

Basically I think, after installed ssh, key files are needed.

The only revision I made was to use rsa instead of rsa1:

ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key 
ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key

That modified method worked for me.

share|improve this answer
This was the problem in my case. The ssh server package with the current Ubuntu release for the Utilite ARM machine installed with the OP's symptom. After running these two commands (which I did as root), I can finally ssh in. Thanks a lot. +1 – Doc Jul 8 '14 at 16:30

It's because somehow the permissions of the files inside /etc/ssh have changed... So change the permission of the files like the example given below:


chmod 644 ssh_config
chmod 600 moduli

and so on...

Finally the file permissions should look like something like given below,

[root@hostname ssh]# ls -latr
total 172

-rw-r--r--.   1 root root   2047 Aug 12  2010 ssh_config
-rw-------.   1 root root 125811 Aug 12  2010 moduli
-rw-------.   1 root root    963 Mar  1 16:02 ssh_host_key
-rw-r--r--.   1 root root    627 Mar  1 16:02
-rw-r--r--.   1 root root    382 Mar  1 16:02
-rw-------.   1 root root   1675 Mar  1 16:02 ssh_host_rsa_key
-rw-r--r--.   1 root root    590 Mar  1 16:02
-rw-------.   1 root root    668 Mar  1 16:02 ssh_host_dsa_key
-rw-------.   1 root root   3845 May  7 11:52 sshd_config

After changing the permissions try connecting from putty, should work fine..

share|improve this answer
Why is Putty relevant? And consider asking the OP what the permissions are on the files before advising that he/she change them. – Clive van Hilten May 20 '13 at 14:02
Extremely sorry for posting the answer in a wrong manner.Now here is the thing,during some app installation someone changed the permissions of these files to 777. This i got to know while going thru /var/log/messages (serial connecting to the machine). Hence changed the permissions, and guess what? it worked fine after that. – Varun Joseph May 21 '13 at 4:18

We had a similar problem, but it occurred only when logging from Ubuntu to Solaris. Making sure all these lines are present in /etc/ssh/ssh_config on the Ubuntu host fixed the problem (you should find some of these lines are already present):

Host *
SendEnv LANG LC_*
HashKnownHosts yes
GSSAPIAuthentication yes
GSSAPIDelegateCredentials no
Ciphers aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc
HostKeyAlgorithms ssh-rsa,ssh-dss
MACs hmac-md5,hmac-sha1,hmac-ripemd160

In the case of Xubuntu I needed only the last two.

share|improve this answer

In my case, the problem comes from multiple attempted attacks. The probleme is stopped immediately after installing feil2band (apt-get install fail2ban).

Hope help.

share|improve this answer
Please explain your answer with more details on why this would work – DnrDevil Feb 13 at 15:03

Your Answer


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.