My SSH connections are failing with kex_exchange_identification

I’m trying to connect with my remote devices, and I received this message.

kex_exchange_identification: Connection closed by remote host
Connection closed by

[Process completed]

Please help!

“kex_exchange_identification: Connection closed by remote host” is a generic message for connections.

If you are on a Mac, there was a change in Ventura version of the OS which which “disables RSA signatures using the SHA-1 hash algorithm” by default. If you are not on a Mac or the solution provided for Mac doesn’t work, please scroll to the bottom for additional debugging steps.

MacOS Ventura encryption fix:

Test the algorithm issue, add the following to your command line:

-oKexAlgorithms=ecdh-sha2-nistp521

OR

-oKexAlgorithms=ecdsa-sha2-nistp256

For example:

ssh -v -oKexAlgorithms=ecdh-sha2-nistp521 -l pi proxy21.rt3.io -p 59000

If your connection now works, you can edit your ssh config file (~/.ssh/config) to add configuration by adding the following line:

KexAlgorithms=ecdh-sha2-nistp521

There are other suggestions on the internet such as https://pratapsharma.com.np/ssh-not-working-in-macos-ventura-fix