How can you debug an ssh connection?

There isn’t public documentation for this but erlang actually has a ssh_dbg module that can be used to enable verbose ssh debug logging.

The most simple usage is to replace :ssh.start() with :ssh_dbg.start() and then also call :ssh_dbg.on() to enable all logging. Though that can be pretty verbose so you might want to only log certain message by passing options to on() (though I don’t know what all supported values are).

This is because such modules are designed exclusively for testing functionality, I would avoid relying heavily on them as I don’t think that backward compatibility applies to them.

That is more erlang than my brain can handle, have you tried posting this question on https://erlangforums.com/ ?