How to fix 'ssh_exchange_identification: read: Connection reset by peer' on mac OS Mojave?
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


Chapter 10: Common error messages