Differentiating between ssh connection failures and ssh command failures

Markus Friedl mfriedl at gmail.com
Fri Sep 18 22:57:13 AEST 2015


true. but never found this to be a problem in practice…

> Am 12.09.2015 um 04:13 schrieb Stephen Harris <lists at spuddy.org>:
> 
> On Sat, Sep 12, 2015 at 11:14:07AM +1000, Damien Miller wrote:
>> ssh server.example.com /usr/bin/do/something
>> r=$?
>> if [ $r -eq 0 ] ; then
>> 	echo success
>> elif [ $r -eq 255 ] ; then
>> 	echo ssh failed
>> else
>> 	echo command failed
>> fi
> 
> 
> ssh remoteserver exit 255
> 
> Hmm :-)
> 
> exit(-1)  aka exit(255) is a pretty standard "generic failure code"
> for many programs.
> 
> The problem, really, is that "exit code" is the wrong thing to test for.
> 
> x=`ssh remoteserver "echo CONNECTED && somecommand"`
> 
> And then see if CONNECTED appears in the output to show successful
> connection.
> 
> -- 
> 
> rgds
> Stephen
> _______________________________________________
> openssh-unix-dev mailing list
> openssh-unix-dev at mindrot.org
> https://lists.mindrot.org/mailman/listinfo/openssh-unix-dev



More information about the openssh-unix-dev mailing list