setting environment for SSH and SCP session

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
Can anyone point me to the docs that tell you how to set the
environment when you execute commands remotely via ssh?.

If I login using "ssh remotehost" then I get a reasonable environment,
probably comes from my .profile, however if I "ssh remotehost command"
then the environment that the command runs in is quite spartan.

What I need to know is how do I configure the environment in the
second case, specifically I need to add the usual */bin paths to the
PATH variable.

My default shell is '/bin/sh'

Re: setting environment for SSH and SCP session

Assuming your shell is bash, read the INVOCATION section of bash(1),
remembering that the shell you get for remote command execution (an SSH
exec channel) is non-interactive in the terminology of that man page.

You don't say what SSH software you're using.  If the server is OpenSSH,
then see ssh(1) regarding PermitUserEnvironment and ~/.ssh/environment.

  Richard Silverman

Site Timeline