exit status of ssh?

Chris Quenelle chris.quenelle at oracle.com
Tue Mar 22 05:47:34 EST 2011

On Saturday March 19    12:39AM, Salvador Fandiño wrote:
> On 03/18/2011 05:52 PM, Chris Quenelle wrote:
>> On Friday March 18 9:41AM, Michael Loftis wrote:
>>> On Thu, Mar 17, 2011 at 5:17 PM, Chris Quenelle
>>> <chris.quenelle at oracle.com> wrote:
>>>> The man page for ssh says that the exit status of ssh should
>>>> be the exit status of the program that it runs.
>>>> The session terminates when the command or shell on the remote machine
>>>> exits and all X11 and TCP/IP connections have been closed. The exit 
>>>> sta‐
>>>> tus of the remote program is returned as the exit status of ssh.
>>>> ...
>>>> ssh exits with the exit status of the remote command or with 255 if an
>>>> error occurred.
>>>> But it doesn't seem to work.
>>>> % bash -c '"/bin/ls /foo"' ; echo $?
>>>> bash: /bin/ls /foo: No such file or directory
>>>> 127
>>>> % ssh cryo bash -c '"/bin/ls /foo"' ; echo $?
>>>> /bin/ls: /foo: No such file or directory
>>>> 0
> What happens when you log in cryo and run the first command there?
> - Salva

cryo gives the same result as on the ssh-originating host:
% ssh cryo
% bash -c '"/bin/ls /foo"' ; echo $?
bash: /bin/ls /foo: No such file or directory

So by reading between the lines, I assume that other
people are not seeing this kind of behavior?

That's very strange.  I haven't yet gone to the trouble of setting
up a new user account with it's own scratch ~/.ssh directory
to see if it is reproducible.

I assumed this was either a bug that nobody noticed, or it was
some kind of pilot error on my part.


More information about the openssh-unix-dev mailing list