7

When I try to ssh to a remote host, I get the following error messages:

root@cloudstack-server-1:~/.ssh# ssh [email protected] -v
OpenSSH_5.9p1 Debian-5ubuntu1.1, OpenSSL 1.0.1 14 Mar 2012
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to 172.17.4.17 [172.17.4.17] port 22.
debug1: Connection established.
debug1: permanently_set_uid: 0/0
debug1: identity file /root/.ssh/id_rsa type 1
debug1: Checking blacklist file /usr/share/ssh/blacklist.RSA-1024
debug1: Checking blacklist file /etc/ssh/blacklist.RSA-1024
debug1: identity file /root/.ssh/id_rsa-cert type -1
debug1: identity file /root/.ssh/id_dsa type 2
debug1: Checking blacklist file /usr/share/ssh/blacklist.DSA-1024
debug1: Checking blacklist file /etc/ssh/blacklist.DSA-1024
debug1: identity file /root/.ssh/id_dsa-cert type -1
debug1: identity file /root/.ssh/id_ecdsa type -1
debug1: identity file /root/.ssh/id_ecdsa-cert type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.9p1 Debian-5ubuntu1.1
debug1: match: OpenSSH_5.9p1 Debian-5ubuntu1.1 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.9p1 Debian-5ubuntu1.1
debug1: SSH2_MSG_KEXINIT sent
Read from socket failed: Connection reset by peer

BTW, I generate a key-pair id_rsa/id_rsa.pub in my local host and paste the id_rsa.pub to the remote host's file authorized_keys. I also enable password login in remote host. Now, I have no idea about the error messages--Read from socket failed: Connection reset by peer. Please give me some advices.

2
  • Can you read the sshd log at remote server? It should contain some information why you cannot connect. Commented Mar 12, 2014 at 4:06
  • Can you try ssh-copy-id [email protected] and enter password on prompt.
    – Ketan
    Commented Mar 12, 2014 at 4:11

5 Answers 5

5

This is almost certainly a permission problem on the server side. Assuming you have some other way of connecting to it (I would not know how you pasted your public key in their otherwise), check the sshd log file ( /var/log/auth.log but depending on your configuration file).

The log should point you in the right direction, but in particular you should set the permissions of ~ubuntu/.ssh on the server to 700 with owner ubuntu. It could also be the permissions of the files in ~ubuntu/.ssh. Or on /etc/ssh or the files in there (which would mean other accounts on the server should have the same ssh login problems).

2

Start monitoring the server's log file

tail -f /var/log/auth.log

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

Note: Keys re-generation definitely work.

2
  • Key gen fixed it for me Commented Feb 14, 2017 at 23:28
  • 1
    Another way of regenerating on Ubuntu is: sudo dpkg-reconfigure openssh-server
    – Michele
    Commented Mar 7, 2017 at 15:00
1

It appears to be an issue of permission, permission for

/etc/ssh/ssh_host_rsa_key
/etc/ssh/ssh_host_dsa_key

should be such that other users can not access these keys.

changed the permission to 700 instead of 755

[root@SC-1 ssh]# ls -l
total 156
-rwxr-xr-x. 1 root root 125811 Nov 21  2013 moduli
-rwxr-xr-x. 1 root root   2047 Nov 21  2013 ssh_config
-rwxr-xr-x. 1 root root   3879 Nov 21  2013 sshd_config
-rwxr-xr-x. 1 root root    668 Dec 18 15:48 ssh_host_dsa_key
-rwxr-xr-x. 1 root root    590 Dec 18 15:48 ssh_host_dsa_key.pub
-rwxr-xr-x. 1 root root    963 Dec 18 15:48 ssh_host_key
-rwxr-xr-x. 1 root root    627 Dec 18 15:48 ssh_host_key.pub
-rwxr-xr-x. 1 root root   1671 Dec 18 15:48 ssh_host_rsa_key
-rwxr-xr-x. 1 root root    382 Dec 18 15:48 ssh_host_rsa_key.pub
[root@SC-1 ssh]# chmod 700 *
[root@SC-1 ssh]# ls -l
total 156
-rwx------. 1 root root 125811 Nov 21  2013 moduli
-rwx------. 1 root root   2047 Nov 21  2013 ssh_config
-rwx------. 1 root root   3879 Nov 21  2013 sshd_config
-rwx------. 1 root root    668 Dec 18 15:48 ssh_host_dsa_key
-rwx------. 1 root root    590 Dec 18 15:48 ssh_host_dsa_key.pub
-rwx------. 1 root root    963 Dec 18 15:48 ssh_host_key
-rwx------. 1 root root    627 Dec 18 15:48 ssh_host_key.pub
-rwx------. 1 root root   1671 Dec 18 15:48 ssh_host_rsa_key
-rwx------. 1 root root    382 Dec 18 15:48 ssh_host_rsa_key.pub
[root@SC-1 ssh]#

it has resolved the issue.

0

I had this exact same issue. My permissions were correct in /etc/ssh and this issue was due to the duplicate IP address on the network. Once that was fixed, the problem disappeared.

-1

In the client's configuration file (/etc/ssh/ssh_config), uncomment lines 42 and 43.

1
  • 7
    Add the line 42 and 43 for reference.. Commented Dec 11, 2014 at 4:50

You must log in to answer this question.

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