Fixing $PATH programmatically for non-interactive SSH

Hi there,

I'm looking for a way to fix programmatically the $PATH after an
incoming SSH connection, not only for remote interactive shells, but
for remote command execution also.

I'm using Debian Lenny with , and currently I have :

user@host:~$ ssh -V
OpenSSH_5.1p1 Debian-5, OpenSSL 0.9.8g 19 Oct 2007
user@host:~$ ssh localhost
user@host:~$ echo $PATH
user@host:~$ exit
user@host:~$ ssh localhost 'echo $PATH'

I would like to add /myowndir to the $PATH for remote command
execution, as well as for remote login shells.

As far I've investigated, $PATH is fixed by /etc/profile for interactive
connection. But unfortunately, for remote command execution, this script
is not executed.

I would like to add this dir to $PATH for all users except the famous
one with uid 0. So, I guess I can't use those basics key/value files
such as /etc/environment or ~/.ssh/environment.

Is there any simple way to deal with such constraints in OpenSSH?
Intuitively, I was thinking of well-thought combination of 'UsePAM yes'
and modules in /etc/pam.d/sshd?

Thanks in advance for any kind of help,
Systems and networks administrator on Grid'5000
INRIA Saclay Building H
tel: +33 1 74 85 42 45 Office 015

Relevant Pages

  • Re: Remote command takes minutes
    ... I'm trying to run a remote command using SSH, ... debug1: Entering interactive session. ... real    7m39.620s ...
  • Re: Tcl catch exec hangs when executing a ssh command with pipe
    ... From the tcl application, I do: ... Perhaps try using option "-x" with ssh, just in case, myprogram ... The OP obviously wants to start a remote command to the remote host's ... expect input on stdin and will wait for stdin to be closed. ...
  • Re: whats the point of ssh for a home user?
    ... Advantages of ssh over telnet other than the cryptographic ... remote command execution: you can say 'ssh server command-line' ... type the command at the remote prompt. ...
  • Re: Can I remote shutdown Linux?
    ... ssh into the box and type 'poweroff' ... >> remote command can be used to turn it off so I dont have to open my ... > to a particular network port, then just access the port over the network. ...
  • RE: ssh remote command fuser does not work
    ... ssh remote command fuser does not work ... Cannot get remote command fuser to work - ... Soalris 8 system running OpenSSH_3.8p1, SSH protocols 1.5/2.0, OpenSSL ...