Persistent SSH sessions

The screen program, among other useful things, lets you keep an SSH session running even after you disconnect from SSH. Here’s how to use it.

SSH in.

ssh user@hostname.com

Once on the remote machine, set up a named screen:

screen -S myscreen

In another terminal, open another SSH connnection and start another screen:

screen -S mysecondscreen

You can see they are there by using, in either of the terminals,

screen -ls

This does NOT start screen, just lists the different screens.

You can now disconnect the SSH connections. When you reconnect, you can use

screen -r myscreen

or

screen -r mysecondscreen

to reconnect to the one you want.

Tags: ,

Leave a Reply