SSH and file descriptors

Dawid Szymanski DSzymanski at axit.pl
Thu Apr 20 21:57:26 EST 2006


Let me start with "I am not sure if problem I describe is really ssh 
problem" so excuse me in that case.


I've needed to make a login shell wrapper for one of users (an example 
below) to my own script:

<script>
#!/bin/bash
ls -la /this_does_not_exist /etc/passed
</script>

(shebang with -l or -i does not  affect the problem)

Real script does not matter, this example is to show you that I cant use 
  error descriptor here;\

When I run this script while being logged on machine I get:

<typescript>
user at machine ~ $ /usr/local/bin/myscript_shell > /dev/null
ls: /this_does_not_exist: No such file or directory
</typescript>

what we can see here is that stderr and stdout are separated...

When I run this script over ssh I get:

<typescript>
user at machine ~ $ ssh machine /usr/local/bin/myscript_shell > /dev/null
Password:
ls: /this_does_not_exist: No such file or directory
</typescript>

here also stderr and stdout are separated...

Now let me change change login shell (in /etc/passwd) for user "user" 
from "bash" to "myscript_shell"... and login again:

<typescript>
user at machine ~ $ ssh machine > /dev/null
Password:
Connection to machine closed.
</typescript>

Hmm, where is my stderr!?;\ to make sure that script is giving the same 
output....

<typescript>
user at machine ~ $ ssh machine
Password:
Last login: Thu Apr 20 13:50:36 2006 from machine
ls: /this_does_not_exist: No such file or directory
-rw-r--r--  1 root root 2515 Apr 20 10:47 /etc/passwd
Connection to machine closed.
</typescript>

Is this ssh dependent? Is this wanted behavior?

I need to have separated descriptors... as in all examples before login 
shell change...

Any clue? Thx.

-- 
Dawid Szymanski, dszymanski at axit.pl, +48 (71) 3352352
AXIT Polska Sp. z o.o., ul. Ruska 51b, 50-079 Wroclaw, Poland




More information about the openssh-unix-dev mailing list