SSH_CLIENT _not_ set when doing a command

Mark D. Baushke mdb at juniper.net
Sat Sep 30 02:25:25 EST 2000


Hi Daniel,

Mike Stone is correct in his message to openssh-unix-dev. Newer
versions of bash do not auto-export the SSH_CLIENT variable.

Looking at past sources, it appears that bash introduced the idea of
unexporting the SSH_CLIENT variable in version 2.02 (not a new feature
of version 2.04 as Mike suggested) and has been in each subsequent
release of bash.

The diffs between 2.01 and 2.02 give the CHANGES entry between
bash-2.02, bash-2.02-alpha1 and bash-2.01.1-release:

+ bb. Bash now attempts to detect when it is being run by sshd, and treats
+     that case identically to being run by rshd.

If bash thinks it is being run by rshd (or sshd), then it processes
the users ~/.bashrc file.

That being the case, adding the following code to your ~/.bashrc should
bring the variable back for users that need/want it.

  if [ -z "$SSH_CLIENT" ]; then export SSH_CLIENT; fi

This should let you work around your problem and still let you use
bash instead of csh or ash as your shell.

	Enjoy!
	-- Mark

>Date: Fri, 29 Sep 2000 07:25:30 -0400
>From: Michael Stone <mstone at cs.loyola.edu>
>To: openssh-unix-dev at mindrot.org
>Subject: Re: SSH_CLIENT _not_ set when doing a command
>Message-ID: <20000929072530.E15994 at justice.loyola.edu>

>
>On Fri, Sep 29, 2000 at 11:34:28AM +1100, Damien Miller wrote:
>> On Thu, 28 Sep 2000, Daniel Saakes wrote:
>> > we (sendy & me) think it is a bash problem.
>> 
>> Are you sure you don't have something in /etc/profile, ~/.bash_profile 
>> etc which is clearing the environment?
>
>Check the source. (It's a new feature of bash 2.04.) bash actually
>does unexport SSH_CLIENT. It's still there if you look at `set`, but
>it's not there if you look at `env`. You'd have to ask the bash people
>why that was a good idea.
>
>-- 
>Mike Stone






More information about the openssh-unix-dev mailing list