Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Activity of the $HOME/.kshrc

57 views
Skip to first unread message

jialin...@cmgl.ca

unread,
Mar 5, 2009, 12:40:53 PM3/5/09
to
Hi,

I have ssh login to two Linux - Openssh server. They share one $Home
directory. server1 runs Redhat 3 with Openssh 3.6.1 and sever2 runs
Redhat 5 with Openssh 4.3

The problem is: If I type "ssh server1 set" in a local host it shows
the variable defined in $HOME/.kshrc. However, "ssh server2 set" does
not show the variable defined in the same $HOME/.kshrc file. How can I
make the server2 works the same as server1? Here the user name in
local, svrever1 and server2 are the same.

Settings of both server1 and server2:

# cat /etc/ssh/sshd_config | grep PermitUserEnvironment
PermitUserEnvironment yes

$ cat $HOME/.ssh/environment
ENV=$HOME/.kshrc

$ cat $HOME/.kshrc
LIC_HOST=licserv; export LIC_HOST;


Results of ssh command:

localhost$ ssh server1 echo $LIC_HOST
licserv
localhost$ ssh server2 echo $LIC_HOST


Any workaround?

Thanks in advance for any discussions.

Jialing

Richard E. Silverman

unread,
Mar 5, 2009, 11:25:28 PM3/5/09
to

I can't replicate this behavior with the named OpenSSH versions, but mine
are running on the same host (Debian). ksh is documented to only read
.kshrc when interactive, and that's the behavior I get. Perhaps the
difference is due to different versions of ksh, rather than OpenSSH?

--
Richard Silverman
r...@qoxp.net

jialin...@cmgl.ca

unread,
Mar 6, 2009, 11:34:49 AM3/6/09
to
>   r...@qoxp.net- Hide quoted text -
>
> - Show quoted text -

The fact is if I do a "real" login (ssh without command), server2 has
the variable be set:
Localhost$ ssh server2
$ hostname
server2


$ cat $HOME/.kshrc
LIC_HOST=licserv; export LIC_HOST;

$ echo $LIC_HOST
licserv

However if do ssh with the commad, the .kshrc does not work (the
LIC_HOST is not set):
Localhost$ ssh server2 echo $LIC_HOST


So I guess when "ssh server2 command" is executed, the command is
running with the "default shell" instead of the "user's shell". The
server1 uses the "user's shell" for "ssh server1 command".

Jialing Liang
jialin...@cmgl.ca

Old Man

unread,
Mar 6, 2009, 1:42:57 PM3/6/09
to

<jialin...@cmgl.ca> wrote in message
news:f1a61e23-94c6-4322...@p36g2000prp.googlegroups.com...

Jialing Liang
jialin...@cmgl.ca

-----------------------
Do you have this in your .profile?

In ksh, the ENV variable names a file that will be

sourced for all ksh invocations.

This is set in ${HOME}/.profile, and then exported.

I have the following in ${HOME}/.profile:

ENV=${HOME}/.kshrc

export ENV

You might see if it helps.

Old Man


jialin...@cmgl.ca

unread,
Mar 6, 2009, 3:29:55 PM3/6/09
to
On Mar 6, 11:42 am, "Old Man" <reply2newsgr...@nowhere.com> wrote:
> <jialing.li...@cmgl.ca> wrote in message
> jialing.li...@cmgl.ca

>
> -----------------------
> Do you have this in your .profile?
>
> In ksh, the ENV variable names a file that will be
>
> sourced for all ksh invocations.
>
> This is set in ${HOME}/.profile, and then exported.
>
> I have the following in ${HOME}/.profile:
>
> ENV=${HOME}/.kshrc
>
> export ENV
>
> You might see if it helps.
>
> Old Man- Hide quoted text -

>
> - Show quoted text -

I have $HOME/.ssh/environment be set as:
$ cat $HOME/.ssh/environment
ENV=$HOME/.kshrc

And the ENV can be confirmed:
localhost$ ssh server2 echo $ENV
$HOME/.kshrc

It seems the "ssh server2 command" does not fully following the ksh
process. Actually, I can force the $HOME/.kshrc be read before the
command. That is:
localhost$ ssh server2 ". $HOME/.kshrc && echo $LIC_HOST"
licserv

That can a workaround but I am still seeking better solution.

Jialing Liang
jialin...@cmgl.ca

0 new messages