I often find myself opening several ssh connections in order to view several log files at a time with tail -f.

This isn't a problem when I'm at home because I use public key encryption for password-less login. However, I will often use computer at my university to do this so I don't have the option of using my private key. It gets annoying to enter my password 4 or 5 times to get several terminal windows.

How can I get multiple terminals over a single connection?

9 Answers 9


Just use GNU screen, it's great as you can start up remote sessions and restore them if your connection drops. It's available as a package for most distributions and may even already be installed on your university system.

The manual will give you all you need to get started, by default all commands are preceeded by Ctrl+A. For example to bring up the onscreen help, just press Ctrl+A then press ?

  • I have been a linux admin for several years and use screen many, many times a day.
    – borodimer
    May 1, 2009 at 5:34
  • No server is complete without screen.
    – Gert M
    May 1, 2009 at 7:03
  • 3
    After using screen for the last few hours I can't believe I lived without it! I've spent 5 years Doing It Wrong.
    – epochwolf
    May 1, 2009 at 7:29

screen allows you to have multiple terminals and more (such as the ability to detach and re-attach to your session).

Some notes to get you going:

Ctrl-a c   create
Ctrl-a d   detach
screen -r  reattach
Ctrl-a a   toggle
Ctrl-a "   list

And some recommended reading:


Take a look at the following two articles on SSH connection sharing:


Basically, do a google search on ssh connection sharing and you'll find a bunch of other articles on it.

  • 1
    Interesting. The one issue is that if my internet connection were to drop I would be unable to reconnect without deleting the socket. If I can't connect how do I get into the server to delete the socket?
    – epochwolf
    May 1, 2009 at 5:29
  • You don't have to delete the socket on the server, it's only a client-side sharing. So you run `ssh foo' once and it creates the socket on the same machine you ran the ssh foo command on. The server sees multiple logins on separate ttys, so it doesn't know any different to "normal" separate logins. May 1, 2009 at 12:44

Possibly, you could use X forwarding to open multiple remote xterms on your local desktop.

  • Server doesn't have X11 installed. Also, not workable on a windows system that I can't install an X server on.
    – epochwolf
    May 1, 2009 at 3:37
  • The Linux server doesn't need to have X11 to run graphical applications that show up on your local desktop. Also, the Cygwin X-Server works great for running things like Firefox from my home Linux box (without X running on my home box) and they show up just fine on my local Windows laptop.
    – shapr
    May 21, 2009 at 19:54

You give no compelling reason why you can't use private keys from the other systems. Generate them per-machine and add the applicable keys to authorized_hosts

Still, use screen.

  • Is using a private key on what amounts to a public computer a good idea? Especially considering I didn't put a passphrase on the key?
    – epochwolf
    May 1, 2009 at 7:31
  • 1
    You wouldn't use the same key as you use elsewhere - you would generate a new key (with a passphrase) and add its public key to the authorized_keys file on your server. Name it something like "portablekey" and take it out of authorized_keys if you think it might have been compromised.
    – Neall
    May 1, 2009 at 11:57

You may also want to look at byobu. It's an enhanced version of Screen and I believe it's a Ubuntu project. But it comes standard with Ubuntu 9.10 and newer.

I tend to still use Screen though by habit but wanted to mention this newer alternative.


If all you're using it for is tailing several files, you may also be interested in multitail.

  • Interesting link. I just mentioned my most common usage. I also need to switch between vim and bash to look up paths for things.
    – epochwolf
    May 1, 2009 at 5:27

One unmentioned screen feature is to "detach" screen and it will keep running whatever commands you have running in that set of screens. Once screen is detached, you can logout and it all keeps chugging away even after logging off. I'll startup screen and then do several c commands to create new 'subscreens'. I can switch between them and start some long running compile or data processing and be assured that my crappy VPN connection won' cause everything to die with it.

After logging off, you can log back in and use 'screen -R' which will re-attach you to your existing screen sessoins.


To use screen with ssh, type

ssh -t <user>@<server> screen -r

(source). man ssh:

-t Force pseudo-terminal allocation. This can be used to execute arbitrary screen-based programs on a remote machine, which can be very useful, e.g. when implementing menu services. Multiple -t options force tty allocation, even if ssh has no local tty.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .