Operating System - HP-UX
1755103 Members
4381 Online
108829 Solutions
New Discussion юеВ

different environment setting Logging locally and remotely

 
SOLVED
Go to solution
Henry Chua
Super Advisor

different environment setting Logging locally and remotely

Hi Guys,

If I want the same user to have different environment setting when they login locally and remotely, how can I acheive this?

Best regards
Henry
5 REPLIES 5
Denver Osborn
Honored Contributor
Solution

Re: different environment setting Logging locally and remotely

When they login in remotely, how do they access the box? Is it via ssh only?

If so, here one way you could do it in their .profile...

ENV_REMOTE=/path/.shrc_remote
ENV_LOCAL=/path/.shrc_local
if [ "${SSH_TTY}X" != "X" ];then
ENV=$ENV_LOCAL
else
ENV=$ENV_REMOTE
fi

Hope this helps,
-denver
Ivan Ferreira
Honored Contributor

Re: different environment setting Logging locally and remotely

You can also use the last command in a script similar to above to verify if the access is local or remote.
Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?
Ralph Grothe
Honored Contributor

Re: different environment setting Logging locally and remotely

If your users' remote logins are through ssh, as suggested by Denver, and probably state of the art nowadays, you could also configure your hosts' ssh servers to honour users' environment by enabling this

e.g.

# grep ^PermitUserEnv /opt/ssh/etc/sshd_config
PermitUserEnvironment yes

Then you can either place the setting of environment variables in the leading option fields of the user's public key (repeated environment option possible)

# grep grothe .ssh/authorized_keys|head -1|cut -c1-94
environment="DAISY_USER=grothe",environment="LANG=C",environment="EXINIT=set ai ic sw=4 ts=4"

or you could create a file named $HOME/.ssh/environment
where you place the usual variable assignments

But please read the warning note in man sshd_config about possible implications of permitting users' environments (especially in respect to preloaded shared libs).
Madness, thy name is system administration
Henry Chua
Super Advisor

Re: different environment setting Logging locally and remotely

Thanks folks,
But is this applicable for all unix platform light SOlaris or Linux? My system is interlink with these.

Regards
Henry

Ralph Grothe
Honored Contributor

Re: different environment setting Logging locally and remotely

If your last question relates to setting the ssh client's environment this is OS independent, I would assume, and should work on any Unix ssh runs on.
(so no difference betw. hpux and solaris)
Madness, thy name is system administration