Automagically set titles to boxes you ssh in screen.
I use GNU Screen a lot – as in basically all the time, and when I SSH somewhere I like to set the title of the screen I’m in, so I can easily keep track of loads of them.
To do this I’ve come up with a script which can be executed by SSH when it connects to a remote server.
http://tuxtraining.com/files/screen_ssh.sh (right click, save as)
and make it executable
chmod u+x ~/screen_ssh.sh
You’ll need to edit
/etc/ssh/ssh/config
and add the following line:
PermitLocalCommand Yes
Then edit the following file:
~/.ssh/config
and set something like this:
Host * LocalCommand /path/to/screen_ssh.sh $PPID %n
This will set the screen title to the name of the machine you SSH’d to and do its best to chop off extraneous Top-Level-Domain information (i.e. if you ssh to foo.company.com the title will be “foo”).
If you have a name defined in your .ssh/config and ssh to that, the screensession name will change to that title. If you ssh to www.server.com it will display www. If you ssh to an IP address it will display the entire IP address.
Instructions and script modified from this site: http://www.tenshu.net/screen_ssh/







