Differentiating between ssh connection failures and ssh command failures

Alex Bligh alex at alex.org.uk
Sat Sep 12 01:25:02 AEST 2015


I'm sure this should be an easy question, but from the ssh client manpage:

EXIT STATUS
     ssh exits with the exit status of the remote command or with 255 if an error occurred.


Let's say I'm using
    ssh server.example.com /usr/bin/do/something
in (e.g.) a bash script.

How can one differentiate between a failure of ssh to connect to the host and the
command in question returning an error? I need to detect both, and differentiate
between them.

-- 
Alex Bligh






More information about the openssh-unix-dev mailing list