Blog about software development


Helping friends on the Linux command-line

15 Aug 2017 - by 'Maurits van der Schee'

I noticed that when I was helping a friend on the Linux command-line I was struggling. Spelling the commands over the phone or trying to read their screen over a bad Skype or Hangout screen sharing connection is not really fun. That's why I spent the time to create something that works (for me at least). It allows your friend to connect to your Linux server on which you can open a shell on your friend's computer.


The connection is secured as it listens only on the localhost of your friends computer and the server. It is a bash shell that is tunneled over SSH to the server using socat. With the tmux terminal program (a younger brother of GNU screen) you can make a terminal that multiple people can view and interact with. This way you can let people show you things while you are on the phone and you can immediately correct it when it is going wrong. Also the other party can see what you do and learn from it. Or if you are doing something that they don't like then they can terminate the session.


These are the main commands of the script:

ssh -R 6000:localhost:6000 -N user@hostname &
tmux new-session -d -s support
socat exec:"tmux attach -t support",pty,raw,echo=0,stderr,setsid,sigint,sane \
      tcp-listen:6000,bind=localhost,reuseaddr &
tmux attach -t support

These above commands you should run on the client, while the following should run on the server:

socat file:`tty`,raw,echo=0 tcp-connect:localhost:6000

You should adjust the "user@hostname" to the rendezvous server that you are using.


When your friend calls you just let him or her connect to your server with socat.sh from my cli-support repository. Your friend probably already has a web-hosting account on a server of yours and if not you may spin up a VM for the occasion. Next you connect to the server and issue the socat server command. From that moment you can see the shell of your friend and you can both type. It is recommended that you also set up an audio connection so that you can talk to each other explaining what you are doing (or trying to do).


I created a tool that helped me helping a few friends with simple Linux problems. It works for me and I can see what they are doing wrong and they can see me do it in a different way and learn from it. These problems have been programming, Git, SSH and DNS related and in most cases I was able to help them out with this tool. There are two things I still want to improve: adjustable screen size on the server (now only the client can resize the screen) and a simple delivery of the tool (I now email the installation commands). Other than that I have not found no issues yet. Does it work for you?


PS: Liked this article? Please share it on Facebook, Twitter or LinkedIn.