VNC into a CircleCI 2.0 job with SSH

VNC into a CircleCI 2.0 job with SSH

SSH access has a lot of uses in debugging a failing job. Here's how you can SSH into a given job to watch browser tests run in real time using VNC:

ssh -p PORT ubuntu@IP_ADDRESS -L 5902:localhost:5901 # To connect via SSH
sudo apt install vnc4server metacity
vnc4server -geometry 1280x1024 -depth 24
export DISPLAY=:1.0
metacity &
firefox &

Be sure to change the IP_ADDRESS to the IP and the PORT to the port you're connecting to. These commands assume you have Firefox installed already, ideally using a CircleCI convenience image.

After running those commands you can connect to localhost:5902 with your VNC client.

Please note that metacity is only required if you want to drag the windows around in the VNC session. It can be helpful to get back to the terminal so I recommend installing it.