1830327 Members
2141 Online
110001 Solutions
New Discussion

Changing Path for sshd

 
Damiano Angelo
Occasional Advisor

Changing Path for sshd

Hi,
We have a problem where we would like to change the path that is available when we run ssh commands. For example running ssh root@target java.

If we run a ssh root@target set, we can see that our path is set to /usr/sbin:/opt/ssh/bin.

We would like to expand the path so that it includes the system $PATH variable. This is so that we can invoke programs that are not available in the sshd path.

We are using HP SSH A 03.81.002_HP-UX_B.11.11
4 REPLIES 4
Slawomir Gora
Honored Contributor

Re: Changing Path for sshd

Hi,

PATH for ssh is set during compilation look at:
to file sshd_config:

In my system:
# This sshd was compiled with PATH=/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bi
n:/usr/bin:/bin

I think that if you want different PATH you must get source OpenSSH code and compile it.
Sridhar Bhaskarla
Honored Contributor

Re: Changing Path for sshd

Hi Damiano,

As said before, PATH is a compiled option. Look at sshd_config. It should have a line saying that "This sshd was compiled with PATH..".

I compile ssh packages with all the customizations I need. Other than with the previous releases which were not included with password expiry option, compiling the latest versions is not looking too bad.

-Sri
You may be disappointed if you fail, but you are doomed if you don't try
Andrew Cowan
Honored Contributor

Re: Changing Path for sshd

You can reset the path for a particular user/session by specifying an environment file that is read when the user connects to the remote system.
I had a problem just recently where a system had Cobol installed, and it used the "scp" command to do something in the compiler, hence when users tried to "scp" files to/from the server it failed.
The solution was to copy the users ".profile"'s to a config file, and then edit the settings to suit.

An extract from the man page:

"-F configfile
Specifies an alternative per-user configuration file. If a con-
figuration file is given on the command line, the system-wide
configuration file (/etc/ssh/ssh_config) will be ignored. The
default for the per-user configuration file is $HOME/.ssh/config."

Muthukumar_5
Honored Contributor

Re: Changing Path for sshd

We can get only the default which was at build time as,
PATH=/usr/bin:/bin:/usr/sbin:/sbin:/opt/ssh/bin

IF we want to change then rebuild is needed. ssh man page for PATH say's as,
It is default and test on config file is not supported to get modified PATH

compile & Rebuild is needed for your requirement
Easy to suggest when don't know about the problem!