Search code examples
bashsshzsh

ssh works on bash but does not work when I use zsh or other terminal, killed on preauth


Recently I have this problem that when I try to log in into a remote box using ssh from a terminal with bash, it connects successfully most of the time. The command I use is just

ssh -vvvv -p PORT USER@IP

Sometimes (very seldomly) I get the following error

OpenSSH_7.9p1, LibreSSL 2.7.3
debug1: Reading configuration data /Users/USER/.ssh/config
debug1: Reading configuration data /etc/ssh/ssh_config
debug2: resolve_canonicalize: hostname IP is address
debug2: ssh_connect_direct
debug1: Connecting to IP [IP] port PORT.
debug1: connect to address IP port PORT: Unknown error: -536870212
ssh: connect to host IP port PORT: Unknown error: -536870212

BUT, I get that error almost ALL the time if I change to zsh (or fish). I have to actually put the ssh command inside a while loop until it is successful. What could be the root cause to this? I have incremented MaxSessions and MaxStartups on the server side. The log files only say te client disconnected on preauth. Can it be that some env vars are affecting locally ssh? Do you have any idea on how to track this and fix it? thank you

Edit: Thanks to @pynexj comment and according to https://communities.apple.com/de/thread/251124631 I had to update openssh. The default version in Mojave is

/usr/bin/ssh -V
OpenSSH_7.9p1, LibreSSL 2.7.3

and after installing a new version with brew the problem was solved

brew install openssh
/usr/local/bin/ssh -V
OpenSSH_8.8p1, OpenSSL 1.1.1l  24 Aug 2021

The ssh connection now works in bash, zsh, fish, etc. So the solution was the usual : update it. Thanks


Solution

  • Thanks to @pynexj, I just had to upgrade my openssh version to fix the problem. First, I had

    $ /usr/bin/ssh -V
    OpenSSH_7.9p1, LibreSSL 2.7.3
    

    Then, after running

    brew install openssh
    

    I got the updated version

    $ /usr/local/bin/ssh -V
    OpenSSH_8.8p1, OpenSSL 1.1.1l  24 Aug 2021
    

    and ssh works on any shell