How to access open terminal with running process using SSH?

I have two computers with Ubuntu 12.04 and 13.10 both desktop versions. On the 12.04 I have opened terminal and process running in it. The process is displaying some states information and allows changing some setting on the fly. So, I want to access the 12.04 from the other PC and manage the process.

I have successfully connected to the PC using SSH, but I was not able to find how to see the process in the terminal.


I believe the tool you are looking for is screen. Be aware that it breaks scrollback due to how it works.

Set up as follows:

screen -mS myscreen

Attach as follows:

screen -x myscreen

Once attached, you or your partner can interact with the screen.

Detach from the screen as follows:

Ctrl-A D

Don't get that backwards, or you log out of your screen and take your partner's with you! If you close the window without detaching, it will close your partner's screen as well.

To list active screens:

screen -ls

To attach to one of two similarly named screens:

screen -x 12345.myscreen

where 12345 is the PID of the screen (which you get from screen -ls)

Found a source for this! http://wiki.networksecuritytoolkit.org/nstwiki/index.php/HowTo_Share_A_Terminal_Session_Using_Screen


If you're trying to access an interactive process like ftp or a game server, you'll only be able to control it from the terminal that created it. That said, there's a program called screen that you can use to create a virtual terminal that can be opened inside other terminals.

To install:

sudo apt-get install screen

To start a screen terminal:

screen -S nameOfScreen

Or if you want to create a screen without connecting to it immediately:

screen -dmS nameOfScreen

And to start a program inside a screen immediately, add the command at the end:

screen -dmS ftpstuff ftp [options for ftp]

You can also reconnect with:

screen -r nameOfScreen

And run a command without entering the screen (useful for scripts):

screen -S gameServer -p 0 -X stuff "alert We're running a backup, expect a bit of lag.$(printf \\r)"

You can disconnect from screen by hitting Ctrl+A followed by Ctrl+D. Try Ctrl+A followed by ? for more help, or read the man page.