Ethical Hacking

Learn to find vulnerabilities before the bad guys do! Gain real world hands on hacking experience in our state of the art hacking lab. Course designed and taught by expert instructors with years of penetration testing experience. 12 student maximum in every class. Certification attempt included in every package.
Computer Forensics Training at InfoSec Institute

Gain the in-demand skills of a certified computer examiner, learn to recover trace data left behind by fraud, theft, and cybercrime perpetrators. Discover the source of computer crime and abuse at your organization so that it never happens again. All of our class sizes are guaranteed to be 12 students or less to facilitate one-on-one interaction with one of our expert instructors.




Network Security Secure-Shell
[Top] [All Lists]

Re: Environment Settings

Subject: Re: Environment Settings
Date: Tue, 10 Jul 2007 08:27:43 -0400
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 tester@localhost 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.)

<Prev in Thread] Current Thread [Next in Thread>