Last edit
Summary: A previous entry documented on how to change your settings in bashrc, according to from which host you logged in over SSH. The solution used the . . .
Changed:
< FROM=$(host -t ptr $FROM_IP | cut -d" " -f5 | cut -d"." -f1)
to
> FROM=$(host -t ptr $FROM_IP | cut -d" " -f5)
Changed:
< myhostname)
to
> myhostname*)
Changed:
< otherhostname)
to
> otherhostname*)
Changed:
< mylaptop|worklaptop)
to
> mylaptop*|worklaptop*)
Added:
> The stars behind the hostnames are there to ignore the domain name. This is because FROM=... line will give you the hostname including domain name, for instance, "mylaptop.company.com."
> If you want to strip off everything but the hostname, use something like
> FROM=$(host -t ptr $FROM_IP | cut -d" " -f5 | cut -d"." -f1)
A previous entry documented on how to change your settings in bashrc, according to from which host you logged in over SSH.
The solution used the hostname entry from the "who"> command. Thing is, it didn't work well because the "who" command also outputs any X sessions.
Here is a script snippet that uses the "host" command. Be sure you install this (under Debian and derivatives available with package dns-utils).
FROM_IP=$(echo $SSH_CLIENT | cut -f1 -d" " | grep -v ":0") FROM=$(host -t ptr $FROM_IP | cut -d" " -f5) case $FROM in myhostname*) # Enter your settings here set -o vi ;; otherhostname*) # Enter your settings here set -o vi ;; mylaptop*|worklaptop*) # Enter your settings here set -o vi ;; esac
The stars behind the hostnames are there to ignore the domain name. This is because FROM=... line will give you the hostname including domain name, for instance, "mylaptop.company.com."
If you want to strip off everything but the hostname, use something like
FROM=$(host -t ptr $FROM_IP | cut -d" " -f5 | cut -d"." -f1)