Skip to content


screen_ssh

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 pulled together ideas and suggestions from a bunch of people to come up with a script which can be executed by SSH when it connects to a remote server.
You’ll need to edit

~/.ssh/config

and set something like this:

Host *
  LocalCommand /path/to/screen_ssh.sh $PPID %n

You may well also need to edit

/etc/ssh/sshd_config

and set something like this:

PermitLocalCommand yes

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”).

You can download the script here: screen_ssh.sh

This is an example, if such a thing were needed:

If you want the blue line to appear at the bottom of your Screen sessions, add this to ~/.screenrc (all on one line):

hardstatus alwayslastline
"%{= bw} %{= bc}[%{-}%0c%{= bc}]%{-} [%-Lw%{= bW}%{+b}%50>%n%f* %t%{-b}%{= bw}%+Lw]%<"

2 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.

  1. PIONNIER says

    Do you know how to use it on mac?

  2. cmsj says

    Pionnier: Unfortunately not, I don’t know how OSX’s ssh stuff works.



Some HTML is OK

or, reply to this post via trackback.