2

I was able to ssh to a Ubuntu 16.04.2 server before reboot. So after reboot I tried to ssh, but failed with message ssh_exchange_identification: read: Connection reset by peer.

Weird part is that, after wait for 10 minutes or so, I am able to ssh to the server. Is there a time lock? If so how to reset that?


Below are my configs on the server:

  • sshd: ALL in /etc/hosts.allow

  • empty in /etc/hosts.deny

  • firewall is inactive ufw status Status: inactive

  • ssh to server as root using public key

  • enabled the following in /etc/ssh/sshd_config

    PermitRootLogin without-password

    PubkeyAuthentication yes

    StrictModes no

    PasswordAuthentication yes

  • In /root/.ssh/config I have the following:

    Host *

    StrictHostKeyChecking no

  • client's pub key is in server /root/.ssh/authorized_keys


A detail log is here: ssh -vvv root@192.168.0.100 OpenSSH_7.2p2 Ubuntu-4ubuntu2.1, OpenSSL 1.0.2g 1 Mar 2016 debug1: Reading configuration data /root/.ssh/config debug1: /root/.ssh/config line 6: Applying options for * debug1: Reading configuration data /etc/ssh/ssh_config debug1: /etc/ssh/ssh_config line 19: Applying options for * debug2: resolving "192.168.0.100" port 22 debug2: ssh_connect_direct: needpriv 0 debug1: Connecting to 192.168.0.100 [192.168.0.100] port 22. debug1: Connection established. debug1: permanently_set_uid: 0/0 debug1: identity file /root/.ssh/id_rsa type 1 debug1: key_load_public: No such file or directory debug1: identity file /root/.ssh/id_rsa-cert type -1 debug1: key_load_public: No such file or directory debug1: identity file /root/.ssh/id_dsa type -1 debug1: key_load_public: No such file or directory debug1: identity file /root/.ssh/id_dsa-cert type -1 debug1: key_load_public: No such file or directory debug1: identity file /root/.ssh/id_ecdsa type -1 debug1: key_load_public: No such file or directory debug1: identity file /root/.ssh/id_ecdsa-cert type -1 debug1: key_load_public: No such file or directory debug1: identity file /root/.ssh/id_ed25519 type -1 debug1: key_load_public: No such file or directory debug1: identity file /root/.ssh/id_ed25519-cert type -1 debug1: Enabling compatibility mode for protocol 2.0 debug1: Local version string SSH-2.0-OpenSSH_7.2p2 Ubuntu-4ubuntu2.1 ssh_exchange_identification: read: Connection reset by peer

Thank you!

3
  • "Connection reset by peer" is very hard to debug, as anything along the chain between you and the server could 'disconnect' the network connection for whatever reason. It's entirely possible that your computer has to be properly on the network before it lets you out, and disconnects you until you've been on for a given period of time, but we can't possibly know whether that's the case just from this. There's no default block, though, that would prevent you from using SSH. – Thomas Ward Nov 28 '17 at 22:33
  • 1
    I would run systemd-analyze on the server and see how long the boot time is. Then if you run it with systemd-analyze blame you can hopefully see maybe something that it causing it to boot slowly. Normally you should be able to ssh to a host once it is up. – Terrance Nov 28 '17 at 22:43
  • Thanks! I finally get it resolved by reinstall the OS. Sadly I would never know the reason. – Antelope Nov 29 '17 at 1:32
0

The way I solved the problem is I went to the host machine and ran a few commands.

sudo mkdir /var/run/sshd
sudo chmod 755 -R /var/run/sshd
sudo service ssh restart

I got connected to the machine after that.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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