SSH Read from socket failed: Connection reset by peer

After installing a container with lxc I wasn’t able to connect via ssh to my container, I get the following message :

root@ns313:~# ssh 10.50.10.10
Read from socket failed: Connection reset by peer

Network works normally, I can ping, hotst both direction and I can get pages from apache’s container from the dom0.

I tried to connect to ssh from container, in local and I get the same error.

root@container:/etc/ssh#ssh 10.50.10.10 -l root
Read from socket failed: Connection reset by peer

Strange, first time ssh doesn’t work on any machine.
Try restart sshd

root@container:/etc/ssh# /etc/init.d/ssh restart
Could not load host key: /etc/ssh/ssh_host_rsa_key
Could not load host key: /etc/ssh/ssh_host_dsa_key
Could not load host key: /etc/ssh/ssh_host_ecdsa_key
[....] Restarting OpenBSD Secure Shell server: sshdCould not load host key: /etc/ssh/ssh_host_rsa_key
Could not load host key: /etc/ssh/ssh_host_dsa_key
Could not load host key: /etc/ssh/ssh_host_ecdsa_key
. ok 

SSH keys are missing, to fix it, run this command :

root@container:/etc/ssh# ssh-keygen -t ecdsa -f /etc/ssh/ssh_host_ecdsa_key -N ''

Leave a Reply