We access our workloads using usrun. Login is automatic as we are either in the profile for that workload or not.
So each user logs into the same account - e.g. wloadexe
Each of the users logs in from a machine where they have their own account. e.g. johndoe
So when they log in, all the files etc.. they create are under the wloadexe profile and everyone logs in using the same .profile though the _history file is unique for each user.
The problem is that everyone want different settings in their profile - but the common profile is loaded each time.
I'm looking for a way to identify the username (johndoe) from the server they logged in from. This must be possible because the history file is set.
e.g. HISTFILE=/wload/bart/home/bartexe/.sh_history_johndoe
SET shows no variables which contain the username other than this one.
there might be several ways to achieve this, and since it's already implemented you should check where and how the HISTFILE variable is set
you can also do it this way:
first on the ssh client:
set in /etc/profile system wide, or in each users profile:
REMOTEUSER=${USER}
add to /etc/ssh/ssh_config
SendEnv REMOTEUSER
on the ssh server:
change /etc/ssh/sshd_config
AcceptEnv REMOTEUSER
restart sshd
every time you log in, the variable REMOTEUSER is set to the ssh clients source username, now you can use this variable to set an user specific environment
You could also use the "who am i" command to see where each user came from and execute other profiles based off of that:
hostname:/:$ who am i
username pts/0 Sep 12 12:27 (remotehost.domain.com)
hostname:/:$ who am i | cut -d\( -f2 | cut -d\) -f1
remotehost.domain.com
hostname:/:$
You could put all your custom changes into profile in $HOME named "profile.johndoe" file and then your current shared profile would have something like this in it near the end to execute your custom profiles:
REMOTE_HOST=$(who am i | cut -d\( -f2 | cut -d\) -f1)
## If the custom profile exists, dot it into the environment
if [ -f $HOME/profile.${REMOTE_HOST} ]; then
. ${HOME}/${REMOTE_HOST}
fi
Of course, this would assume they are all coming from different originating hosts.