Connecting to a remote screen session

Posted 2013-05-15
Written by Matt Frost
Category code

As I'm starting to transition from being in the office on a regular basis to being a full-time remote employee; I've already come to realize that to maximize my productivity and efficiency, I need to take advantage of the tools available to me. I started with Synacor in late April and quickly found that if I was going to get up to speed, it was going to be very important to do a fair amount of pair programming. I've tried the, Skype and Google Hangouts as a way to pair program (both in the past and the present) and found the lack of interaction to be a little bit frustrating. So my first week in Buffalo, one of my coworkers and I decided we were going to learn how to connect to another user's screen session, it didn't take very long to figure out and has been very helpful in collaboration as I start to get up to speed.

Before I go through the steps to configure screen to do your bidding, you'll need to be able to ssh to the other person's computer. Some set-ups are configured for this quite nicely, while others aren't as friendly; if you have questions about security talk to your network administrator. In a couple quick steps, you'll have screen setup to accept remote connections.

1) Install screen, if you don't have it you'll obviously need it to continue:

sudo apt-get install screen
sudo yum install screen
(for Aptitude and Yum, if you use a different package manager, you should be able to find and install it just as quickly)

2) Turn on the setuid bit on screen and change the permissions to 755

sudo chmod u+s /usr/bin/screen sudo chmod 755 /var/run/screen
The setuid bit is off by default, so you'll need to turn it on and make sure that your permissions are set to allow a remote user to execute screen.

3) The user connecting to the screen session needs to know the name of the session, it can be set explicitly using the -S flag

screen -S ticket-12345

4) In command mode you need to turn multiuser on, in case you weren't aware Ctrl-A will enter command mode in a screen session

Ctrl-A :multiuser on

5) Once you have multiuser turned on, you can specify the users that are allowed to connect to the session (again using command mode) with the acladd command.

Ctrl-A :acladd <username>

6) The user that wishes to connect to the screen session then needs to connect to the computer hosting the screen session with ssh.

ssh user@host

7) Finally, the user should be able to use the screen command with the -x flag to connect to the session. The user will need to know the name of the screen session, so be sure to share to that (otherwise screen --list will show all the available screen sessions). The -x flag allows you to connect to a screen session that isn't currently detached, and is only available in multiuser mode.

screen -x hostUserName/ticket-12345

From there, both users should be able to type and see the changes in pretty close to real-time. The benefits to sharing a screen session are obvious, regardless of whether or not an employee is new. I can attest that using this functionality for onboarding has been very helpful for me. It's a real benefit to be able to view code being written by someone else the same way you'd see it if you were writing it; and other screen sharing tools can be difficult to use in certain situations. This isn't to discount the value of the other tools, but using screen in this manner is a great way to interactively pair program with people who aren't sitting right next to you.


Adam Culp


Thanks for this. Knew it was possible, but have not used it. Will try it now.

Posting comments after has been disabled.