3

I suddenly can't connect to my Raspberry Pi from my laptop. In Terminal, I try to access with the command ssh [email protected] and I get this message:

ssh_exchange_identification: read: Connection reset by peer

I have searched for answers but nothing works:

  1. sudo rm /etc/ssh/ssh_host_* didn't result in anything..
  2. sudo dpkg-reconfigure openssh-server gave: sudo: dpkg-reconfigure: command not found
  3. ssh -vv [email protected] gave:

    OpenSSH_7.9p1, LibreSSL 2.7.3
    debug1: Reading configuration data /etc/ssh/ssh_config
    debug1: /etc/ssh/ssh_config line 48: Applying options for *
    debug2: resolve_canonicalize: hostname 192.168.XX.XXX is address
    debug2: ssh_connect_direct
    debug1: Connecting to 192.168.XX.XXX [192.168.XX.XXX] port 22.
    debug1: Connection established.
    debug1: identity file /Users/peterwesterlund/.ssh/id_rsa type -1
    debug1: identity file /Users/peterwesterlund/.ssh/id_rsa-cert type -1
    debug1: identity file /Users/peterwesterlund/.ssh/id_dsa type -1
    debug1: identity file /Users/peterwesterlund/.ssh/id_dsa-cert type -1
    debug1: identity file /Users/peterwesterlund/.ssh/id_ecdsa type -1
    debug1: identity file /Users/peterwesterlund/.ssh/id_ecdsa-cert type -1
    debug1: identity file /Users/peterwesterlund/.ssh/id_ed25519 type -1
    debug1: identity file /Users/peterwesterlund/.ssh/id_ed25519-cert type -1
    debug1: identity file /Users/peterwesterlund/.ssh/id_xmss type -1
    debug1: identity file /Users/peterwesterlund/.ssh/id_xmss-cert type -1
    debug1: Local version string SSH-2.0-OpenSSH_7.9
    ssh_exchange_identification: read: Connection reset by peer
    
  4. sudo rm /etc/ssh/ssh_host_* gave: rm: /etc/ssh/ssh_host_*: No such file or directory

  5. lsof -n | grep ssh | grep DEL didn't do anything

I'm not very good or comfortable with command lines. So I don't really know what things above mean but I found those things when I searched for solutions online.

Edit: On request, here is the list of devices connected to my network and you see my Raspberry Pi/Hassbian there: enter image description here

12
  • First question - are you sure you have the IP address on the Pi correct and you are not linking back to your laptop? You can put the full IP address of internal networks on the internet safely as we cannot access them and it really helps debugging.
    – user115418
    Apr 13, 2020 at 18:44
  • @Andyroo Okay, I have now edited my original post with an image of the devices to my network where you can see my Raspberry Pi/hassbian. Apr 13, 2020 at 20:37
  • Going by github.com/home-assistant/hassio-addons/blob/master/ssh/… you need to add an add-on to enable ssh. If you can get into the Pi locally, then the auth.log should give a clue. It maybe worth clearing the local machines ssh keys for the machine and IP address.
    – user115418
    Apr 13, 2020 at 21:02
  • @Andyroo But I have been able to connect the other day. So why would ssh become disabled by itself suddenly? It's quite a project for me to get into the Pi locally since I don't own an external keyboard and mouse. I remember when I installed the Pi that I borrowed from friend and family. But if that's my only option then I guess I have to. Apr 13, 2020 at 21:13
  • possible change of IP address to another one that had a Pi on it? I now try and avoid IP address based SSH and only use the name then it’s a simple hack to remove the raspberry pi entry in the ssh file. What machine are you using to connect to the Pi? If it’s a Mac then the file can be edited from the terminal using nano - it’s hidden away in ~/.ssh off the top of my head.
    – user115418
    Apr 13, 2020 at 21:51

2 Answers 2

3

As far as I can see from the extended logging of the ssh connection you are only using key file authentication, but no password authentication. That is good for improved security. But the ssh client tries to find a valid identity file in /Users/peterwesterlund/.ssh/, but all possible identity files are quit with -1, that means not found. It seems you have lost your private identity key file on the client, or it is moved to another location, or you had password authentication and on the ssh server it was disabled.

1
  • To check if you still have any keys on the Mac go into the terminal and use the command ls .ssh/ and you should see id_rsa and id_rsa.pub files along with known_hosts. If not you can regen them by issuing the command ssh-keygen -t rsa - DO NOT use a password else you will have to enter it each time! Send this over to the Pi with ssh-copy-id [email protected] and use the Pi password IF IT LETS YOU.
    – user115418
    Apr 14, 2020 at 14:59
2

Actually I solved the problem by just break the power from the Raspberry Pi and then power it on again and then connect with ssh.

2
  • 4
    I came to this thread because after the SSH connection hangs and won't reconnect, I'm forced to kill the pi, but this seems like an extremely poor solution to the problem.
    – ggorlen
    Jan 21, 2021 at 17:14
  • I tried this and it worked! Now I'm left wondering what breaks sshd in the first place ...
    – samvv
    Mar 16 at 11:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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