2

I am trying to connect to my Raspberry Pi over ssh using my MacBook. The command ssh -v pi@ipadress gives the following output:

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 *
debug1: Connecting to localhost port 2222.
debug1: Connection established.
debug1: identity file /Users/Nico/.ssh/id_rsa type -1
debug1: identity file /Users/Nico/.ssh/id_rsa-cert type -1
debug1: identity file /Users/Nico/.ssh/id_dsa type -1
debug1: identity file /Users/Nico/.ssh/id_dsa-cert type -1
debug1: identity file /Users/Nico/.ssh/id_ecdsa type -1
debug1: identity file /Users/Nico/.ssh/id_ecdsa-cert type -1
debug1: identity file /Users/Nico/.ssh/id_ed25519 type -1
debug1: identity file /Users/Nico/.ssh/id_ed25519-cert type -1
debug1: identity file /Users/Nico/.ssh/id_xmss type -1
debug1: identity file /Users/Nico/.ssh/id_xmss-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_7.9
ssh_exchange_identification: read: Connection reset by peer

I have tried all the answers from other threads but could not get it working. Weirdly though, it works on my iMac without any problems. Is there a way to completely reset all the ssh configurations on my MacBook? I had to recently restore my MacBook from a TimeMachine backup, could it be that the problems come from there?

1
  • This is not linked to OSX, this is purely linked to SSH software. Common cause could be that the time machine backup restored the same mac address which doesn't correspond to the new identity of the computer, but that's a wild guess. See here for answers unix.stackexchange.com/questions/151860/… you will need access to your rpi which you have via the other mac Apr 29, 2019 at 11:30

3 Answers 3

2

SSH debugging can be notoriously tricky. I'd start with adding additional -v's to your ssh command to get additional logging from your SSH client.

$ ssh -vv   ...
$ ssh -vvv  ...
$ ssh -vvvv ...

This will return more and more logging from ssh as you add them. The message you're receiving indicates that the server (the peer) is resetting the connection from your ssh client.

This can happen for a variety of reasons one of which is the host is unable to establish (fork) an SSH daemon for your client to connect to. I would suggest rebooting the RPi as a first level of debugging this.

Reference: ssh_exchange_identification: Connection closed by remote host (not using hosts.deny)

It's very likely that this won't be your issue. If it proves not to be there are additional levels of debugging that you can go through to continue to narrow what's causing your issue here.

msg - debug1: Connecting to localhost port 2222

The port you're using to connect is not a standard port, so you might want to investigate if that's intentional or accidental that you're connecting to the SSHD daemon on the RPi is configured to listen on port 2222 or if you're meaning to connect to the RPi via the default port of 22.

References

3
  • Thanks a lot for your help, I was just able to figure out my problem. Even though ssh -vvv ... didn't produce any more output, I investigated further in what I've got. I became suspicious of the line debug1: Connecting to localhost port 2222. and discovered that it was always trying to connect to localhost on port 2222 because of an alias I've created a long time ago in the bash_profile to be able to quickly ssh over usb. Apr 29, 2019 at 15:47
  • @sk8r - ah. Yeah port 2222 isn't the default, should be port 22.
    – slm
    Apr 29, 2019 at 16:02
  • @sk8r - updated the A'er to reflect your new info as well.
    – slm
    Apr 29, 2019 at 16:08
0

I have just had the same issue and after some head-scratching it turns out to have been a mis-configured ssh configuration file. I want to limit log on authentication to ssh keys only and had updated /etc/ssh/sshd_config file, but made a mistake. I suggest you check your ssh configuration file carefully.

In my case I set some parameters with the value No (capital first letter, but when I changed to no (all lower case) ssh to the machine started to work.

0

If you attempted to edit your sshd configuration file you might have saved it as a plain text copy (because Mac does not allow you to directly edit the file). If you did then change the file type from plain text --> text edit. This worked for me.

You must log in to answer this question.

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