Nov 20 2008

Environment Variables and SSH

Published by at 11:58 pm under SSH




Very few environment variables are defined when connecting to a remote host with an SSH authorized key.
 

# ssh localhost env
SHELL=/bin/bash
SSH_CLIENT=127.0.0.1 53816 22
USER=dave
MAIL=/var/mail/dave
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
PWD=/home/dave
LANG=en_US.UTF-8
SHLVL=1
HOME=/home/dave
LOGNAME=dave
SSH_CONNECTION=127.0.0.1 53816 127.0.0.1 22
_=/usr/bin/env

 
To run a program calling libs from an unusual location, we’d need to redefine the LD_LIBRARY_PATH variable for instance.
This can be achieved in 2 steps:
– Add ‘PermitUserEnvironment yes’ to your sshd_config file and restart the ssh service.
Rem: Default value is set to ‘No’.
– Define your environment variables in .ssh/environment on the target host.
eg LD_LIBRARY_PATH=/lib:/usr/lib:/usr/local/lib


One response so far

One Response to “Environment Variables and SSH”

  1. Lakshmipathion 15 Mar 2010 at 2:19 pm

    Thanks,I was search for this piece of info 🙂

Comments RSS

Leave a Reply