On Mon, Jul 09, 2007 at 01:48:31PM -0600, Jialing Liang wrote:
> I am using normal Unix shell (ksh).
>  
> [...] I hope to see the 'environment variables' if I
> type the following command line:
> 
> ssh host1 set 

That shows shell variables as well as environment variables, but doesn't
otherwise change the problem.

> As I tried, the above command does not read the dotfiles

Sure it does.  Or at least, it can be made to do so.

1) Set "PermitUserEnvironment yes" in sshd_config.
2) Put "ENV=$HOME/.kshrc" in ~/.ssh/environment on the server.
3) Put "barney=rubble" in ~/.kshrc on the server.
4) Put your public key in ~/.ssh/authorized_keys on the server.

Here's what I get:

# grep tester /etc/passwd                                               
tester:x:9998:9998:User account for testing:/home/tester:/bin/ksh

# grep Environment /usr/local/etc/sshd_config
PermitUserEnvironment yes

# cat ~tester/.ssh/environment
ENV=$HOME/.kshrc

# cat ~tester/.kshrc
barney=rubble

imadev:~$ ssh [EMAIL PROTECTED] set | grep barney
barney=rubble

If you only wanted environment variables, rather than SHELL variables
(in other words, if you expected to run "ssh host1 env" instead of
"ssh host1 set"), you could bypass ~/.kshrc and simply drop the variables
directly into ~/.ssh/environment in the first place.

(In fact, I could have done that in my test, and the "barney" variable
would still have shown up in the output of "set", except that this time
it would have been an environment variable, not just an un-exported
shell variable.  I just wanted to demonstrate the more difficult case.)

Reply via email to