I am trying to check that an SSH connection succeeds (while running a script).
I am trying to use the answer from here, but the unsuccessful connection returns an error code of 0.
$ ssh -q user@downhost exit
$ echo $?
0
I have tried a variety of invalid ssh
commands but they all return a 0
return code; making it hard to check for failure.
I feel I must be doing something wrong, but can't work it out. Is there some setting that I have changed maybe?
I am running CentOS 7, with the following SSH version:
$ ssh -V
OpenSSH_6.6.1p1, OpenSSL 1.0.1e-fips 11 Feb 2013