SSH + Screen = Easy Administration

I have access to a numerous amount of Linux machines for work and personal matters. Instead of having a ton of different SSH or PuTTY windows open, each connected to a server that I administrate, I decided to use screen to connect to all of them, and manage each one in a different screen window.

Before getting into my screen configuration, its also important to note that on top of my screen setup, I have also configured SSH to authenticate via SSH keys, so I wouldn’t have to always type the password when admining from my “playbox”.

Here is how I set up SSH keys.

I Basically have a single linux machine that I connect to each day at work via PuTTY. We will call that machine my playbox.

From playbox command line, logged in as the user adam I typed the following:

adam@playbox:~$ ssh-keygen -t dsa
Generating public/private dsa key pair.
Enter file in which to save the key (/home/adam/.ssh/id_dsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in id_dsa.
Your public key has been saved in
The key fingerprint is:

The next step was to copy over the file to all the machines I normally SSH to from my playbox.

In this example, I am copying the file from my playbox, to a machine called webserver. For this, I did the following:

adam@playbox:~$ scp ~/.ssh/ adam@webserver:.

After the copy completed, I had to ssh to the webserver machine one last time using a password.

adam@playbox:~$ ssh adam@webserver

Once connected to the webserver via SSH, I needed to move the file into the ~/.ssh/ folder. It is important to note that I had never attempted to ssh from this machine before logged in as the user adam, so a ~/.ssh/ folder did not exist. I simply did the following:

adam@webserver:~$ ssh adam@playbox

After letting SSH attempt to connect I just closed it down by hitting CTRL-C and there was now the ~/.ssh/ folder. Now I could move the file into place, naming it authorized_keys2.

adam@webserver:~$ mv ~/.ssh/authorized_keys2

Once we have the file in place on the webserver, we can now exit and go back to our playbox prompt. Now we should be able to log into the webserver machine without being prompted for a password.

adam@playbox:~$ ssh webserver
Linux 2.6.17.

Now, repeat the steps above using scp to copy over the file to all your other servers ~/.ssh/ folders!

Now that we have the SSH keys set up, we can configure our screen setup.

The first thing I did was locate my .screenrc file and open it in vim. The only modifications I made was adding lines for each of my machines.

screen -t webserver ssh webserver
screen -t mailserver ssh mailserver
screen -t ftpserver ssh ftpserver
screen -t development ssh development
screen -t fileserver ssh fileserver

The above commands will create seperate windows in screen, name them, and connect to each of my servers. It is important to note that I have previously made entries in my /etc/hosts file so that I would not need to type out IP addresses for each server.

After modifiying my ~/.screenrc file, I saved it and simply ran screen.

adam@playbox:~$ screen

Now you can see, by hitting CTRL-A Shift-” that all of your windows are present, and everything has been logged in for you.

Num Name Flags

0 webserver $
1 mailserver $
2 ftpserver $
3 development $
4 fileserver $

I find it much easier to administrate multiple machines this way. You could even create multiple windows per each server if you wanted to by adding more lines to the .screenrc, or by creating new windows on-the-fly by using the CTRL-A CTRL-C switch.

That is all for now. I may add more to this later as I think of other things. For more information on screen, see the man page here.

3 thoughts on “SSH + Screen = Easy Administration

  1. Pingback: Anonymous

  2. Pingback: Myglobalblog » Blog Archive » life is about using screen with SSH

  3. Don’t try and use fancy language if you’re going to fall on your face doing it. For things with which you would use the word “much”, you also use the word “amount”. For things with which you would use the word “many”, you also use the word “number” or “numerous”. “Numerous amount” mixes the two, and I can’t think of any grammatically correct construction where it could be used, even using corner cases such as “many waters.” You shouldn’t say “I have access to much Linux machines”, so neither should you say “I have access to a great amount of Linux machines”. “I have access to many Linux machines” is grammatically correct, so it would also be grammatical to say “I have access to numerous Linux machines” or “I have access to a great number of Linux machines.”

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>