Connection reset by {ssh hostname} port 22

40,970

I had this problem too.

Here's the solution that worked for me: https://raspberrypi.stackexchange.com/a/60375/26923

In essence:

rm /etc/ssh/ssh_host_*
dpkg-reconfigure openssh-server

I believe the problem is that the keypair files that are generated on first boot were corrupt (perhaps from plugging and unplugging power during the setup process).

Share:
40,970
Author by

liz

Updated on July 05, 2022

Comments

  • liz 11 months

    I'm trying to set up a raspberry pi with the command ssh [email protected] but I keep getting these messages:

    ssh -v [email protected] 
    OpenSSH_7.4p1, LibreSSL 2.5.0
    debug1: Reading configuration data /etc/ssh/ssh_config
    debug1: /etc/ssh/ssh_config line 53: Applying options for *
    debug1: Connecting to raspberrypi.local [2601:47:4001:d250:88ff:ddb5:f761:74d2] port 22.
    debug1: Connection established.
    debug1: identity file /Users/liz/.ssh/id_rsa type 1
    debug1: key_load_public: No such file or directory
    debug1: identity file /Users/liz/.ssh/id_rsa-cert type -1
    debug1: key_load_public: No such file or directory
    debug1: identity file /Users/liz/.ssh/id_dsa type -1
    debug1: key_load_public: No such file or directory
    debug1: identity file /Users/liz/.ssh/id_dsa-cert type -1
    debug1: key_load_public: No such file or directory
    debug1: identity file /Users/liz/.ssh/id_ecdsa type -1
    debug1: key_load_public: No such file or directory
    debug1: identity file /Users/liz/.ssh/id_ecdsa-cert type -1
    debug1: key_load_public: No such file or directory
    debug1: identity file /Users/liz/.ssh/id_ed25519 type -1
    debug1: key_load_public: No such file or directory
    debug1: identity file /Users/liz/.ssh/id_ed25519-cert type -1
    debug1: Enabling compatibility mode for protocol 2.0
    debug1: Local version string SSH-2.0-OpenSSH_7.4
    debug1: Remote protocol version 2.0, remote software version OpenSSH_7.4p1 Raspbian-10+deb9u1
    debug1: match: OpenSSH_7.4p1 Raspbian-10+deb9u1 pat OpenSSH* compat 0x04000000
    debug1: Authenticating to raspberrypi.local:22 as 'pi'
    debug1: SSH2_MSG_KEXINIT sent
    Connection reset by 2601:47:4001:d250:88ff:ddb5:f761:74d2 port 22
    

    I have a hunch that it has something to do with the fact that I previously ssh-ed into a different raspberry pi with the exact same hostname and username, but I don't know how to fix it so that I can access this one (and probably rename it to avoid this problem in the future). I tried doing ssh-keygen -R raspberrypi.local but I'm still getting the same messages. Is there more I need to do to remove it? I'm also using a mac running on Sierra 10.12.6. I tried looking through similar issues but couldn't find anything that worked. Thanks!

  • TamusJRoyce
    TamusJRoyce over 4 years
    Expanding the partition via raspi-config. Then enabling ssh. I knew better. But I wanted to see, since it gave no warning (other than a reset was necessary... might not have read past that).
  • Merkle Groot
    Merkle Groot over 3 years
    Worked for me. Thanks!