Connection reset by {ssh hostname} port 22 - ssh

I'm trying to set up a raspberry pi with the command ssh pi#raspberrypi.local but I keep getting these messages:
ssh -v pi#raspberrypi.local
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!

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).

I ended up installing dpkg via homebrew, and re-flashing the SSD card and then it worked. Not really sure why it was so finicky but helpful information in case anyone else runs into a similar issue.

Related

ssh stop at SSH2_MSG_KEXINIT sent while while connecting to LXC container

I can't connect to a lxc container via ssh, when running on the verbose mode it gives the following debug messages :
moelf#moelf:/$ ssh -v root#10.0.3.13
OpenSSH_7.2p2 Ubuntu-4ubuntu2.4, OpenSSL 1.0.2g 1 Mar 2016
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to 10.0.3.13 [10.0.3.13] port 22.
debug1: Connection established.
debug1: key_load_public: No such file or directory
debug1: identity file /home/moelf/.ssh/id_rsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/moelf/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/moelf/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/moelf/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/moelf/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/moelf/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/moelf/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/moelf/.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.4
debug1: Remote protocol version 2.0, remote software version OpenSSH_6.7p1 Debian-5
debug1: match: OpenSSH_6.7p1 Debian-5 pat OpenSSH* compat 0x04000000
debug1: Authenticating to 10.0.3.13:22 as 'root'
debug1: SSH2_MSG_KEXINIT sent
Connection reset by 10.0.3.13 port 22
I looked all over the internet but all the solution seems not working for me.
PS : I can connect to other LXC Containers on the same machine.

Unable to SSH into Vagrant guest

Until recently I was able to SSH into my Vagrant machine without any problems. Now however:
$ ssh -vvv vagrant#127.0.0.1 -p 2222
OpenSSH_7.2p2 Ubuntu-4ubuntu2.1, OpenSSL 1.0.2g 1 Mar 2016
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug2: resolving "127.0.0.1" port 2222
debug2: ssh_connect_direct: needpriv 0
debug1: Connecting to 127.0.0.1 [127.0.0.1] port 2222.
debug1: Connection established.
debug1: key_load_public: No such file or directory
debug1: identity file /home/user1/.ssh/id_rsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/user1/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/user1/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/user1/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/user1/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/user1/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/user1/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/user1/.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
I checked /etc/hosts.allow and /etc/hosts.deny in the guest. Nothing there. I'm almost sure this has something to do with someone rewriting the contents of /etc/resolv.conf. The contents are now:
nameserver 8.8.8.8
nameserver 8.8.4.4
The network seems to be fine on the host where I can ping google.com, but not on the guest, where I can't. But SSH to the Vagrant machine is no longer working. Any ideas?
The answer is not at all what I expected. In VirtualBox Settings > Network > Adapter 1 the Cable Connected option was disabled. After enabling it everything went back to normal.

SSH Hangs on "Entering interactive session" stage

I built an image with yocto project for Banana Pro board. I am trying to connect port via ssh root#10.1.80.x but I couldn't.
Ssh always hangs on the Entering interactive session stage. When I run ssh -v parameter, I captured below logs :
OpenSSH_6.9p1 Ubuntu-2ubuntu0.1, OpenSSL 1.0.2d 9 Jul 2015
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to 10.1.80.41 [10.1.80.41] port 22.
debug1: Connection established.
debug1: key_load_public: No such file or directory
debug1: identity file /home/yusuf/.ssh/id_rsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/yusuf/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/yusuf/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/yusuf/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/yusuf/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/yusuf/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/yusuf/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/yusuf/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.9p1 Ubuntu-2ubuntu0.1
debug1: Remote protocol version 2.0, remote software version OpenSSH_7.1
debug1: match: OpenSSH_7.1 pat OpenSSH* compat 0x04000000
debug1: Authenticating to 10.1.80.41:22 as 'root'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client chacha20-poly1305#openssh.com none
debug1: kex: client->server chacha20-poly1305#openssh.com none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ecdsa-sha2-nistp256
SHA256:XpqS0ZXhoF/OsBmiD8bkpWaZ6Fbk5T3a2Xdq2E8127w
The authenticity of host '10.1.80.41 (10.1.80.41)' can't be established. ECDSA key
fingerprint is SHA256:XpqS0ZXhoF/OsBmiD8bkpWaZ6Fbk5T3a2Xdq2E8127w. Are
you sure you want to continue connecting (yes/no)? yes
Warning:
Permanently added '10.1.80.41' (ECDSA) to the list of known hosts.
debug1: SSH2_MSG_NEWKEYS sent debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received debug1: SSH2_MSG_SERVICE_REQUEST
sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentication succeeded (none). Authenticated to 10.1.80.41 ([10.1.80.41]:22).
debug1: channel 0: new [client-session]
debug1: Requesting no-more-sessions#openssh.com
debug1: Entering interactive session.
I tried to change MTU but it didn't work.
How can I solve this problem?
Problem has been solved purely by chance.And I don't know why.
Normally, I had been running modprobe sunxi-gmac and /etc/init.d/networking restart commands manually after booting with ethernet cable attached.
But this time, accidentally,I forgot to plug the cable beforehand, but plugged during /etc/init.d/networking restart command was running (Sending discover stage).
To my surprise, ssh connection has been achieved! This behaviour is deterministic(Tried enough).
Can anyone explain this weird situation? Why should I plug the ethernet cable during network is restarting and not before that?

CentOS 6 Connection closed by remote host

After installing owncloud and running the MySQL secure setup I can not connect to the server anymore. I get the following error:
MacBook-Pro:~ username$ ssh -i ~/.ssh/authorized_keys2 root#x.x.x.x -v
OpenSSH_6.9p1, LibreSSL 2.1.8
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 21: Applying options for *
debug1: Connecting to x.x.x.x [x.x.x.x] port 22.
debug1: Connection established.
debug1: key_load_public: No such file or directory
debug1: identity file /Users/username/.ssh/authorized_keys2 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/username/.ssh/authorized_keys2-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.9
ssh_exchange_identification: Connection closed by remote host
Whats going on and how can I fix it? I still have an active conneciton to the server
Check /var/log/messages file and see what the error message is. In many case it just a misconfiguration of permission.

ssh stuck on SSH2_MSG_KEX_DH_GEX_REQUEST(1024<7680<8192) sent

I can connect to vpn via networkmanager and openconnect plugin.
But when I connect to company's server,I got logs below:
[root#XSign ssh]# ssh username#xxx -v
OpenSSH_7.1p1, OpenSSL 1.0.2d 9 Jul 2015
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Connecting to xxx [x.x.x.x] port 22.
debug1: Connection established.
debug1: permanently_set_uid: 0/0
debug1: key_load_public: No such file or directory
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.1
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.3
debug1: match: OpenSSH_5.3 pat OpenSSH_5* compat 0x0c000000
debug1: Authenticating to xxx:22 as 'username'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr umac-64#openssh.com none
debug1: kex: client->server aes128-ctr umac-64#openssh.com none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<3072<8192) sent
Then it is stucked on last line.
I can connect to xxx server when I am in company.
I can connect this xxx server with my previous laptop via same network at home.
Difference between these 2 laptops are the softwares version.
Anybody knows y I got a stuck ?
MACs hmac-md5,hmac-sha1,umac-64#openssh.com,hmac-ripemd160
undocument above line in /etc/ssh/ssh_config,solved the problem.
it appears that your target server does not support modern HMACs and only allows older (possibly insecure) HMACs. The default SSH client settings on your source machine is therefore preventing the connection.
You can override this on a case-by-case basis, eg:
ssh -m umac-64#openssh.com targetserver
ssh -m hmac-sha1 targetserver
ssh -m hmac-md5 targetserver
.
Or, as suggested by #hacksign above, you can permanently allow the use of (possibly) insecure HMACs, by un-commenting the following line in /etc/ssh/ssh_config :
MACs hmac-md5,hmac-sha1,umac-64#openssh.com,hmac-ripemd160
Try to adapt the MTU size.
I had the same problem (with another tunnel) and setting the MTU size to something smaller fixed the problem for me.