1
What's the most reliable way to distinguish local from remote logins in .bashrc?
1
What's the most reliable way to distinguish local from remote logins in .bashrc?
1
Check out the env
command time. I find that when I ssh into a remote host that a variable called $SSH_CLIENT
is set and it's value is the IP address from which I am connecting.
You could check to see if that variable is null or not.
if [ -z "$SSH_CLIENT" ]; then
// code when local login
else
// code when remote login
fi
0
If you use ssh
(as you really should :) you can look for environment variables starting with $SSH_
. Another way is who -u am i
, which will show a hostname for remote logins.