Skip to content

Instantly share code, notes, and snippets.

@adamcrosby
Last active December 24, 2020 19:29
Show Gist options
  • Save adamcrosby/fc2b25ab70ca3188aff298587e7cc8e5 to your computer and use it in GitHub Desktop.
Save adamcrosby/fc2b25ab70ca3188aff298587e7cc8e5 to your computer and use it in GitHub Desktop.

Getting linux up with vnc from macOS:

Launch a Ubuntu 20.04 LTS Server as an EC2 instance, and ensure you have a security group that allows you to access it via SSH (and SSH only, you'll be using SSH to port tunnel VNC).

Once you've got the instance up, and have ssh'd in, run the following to install the packages necessary for a basic desktop environment (not included by default in the Ubuntu server install on AWS).

sudo update
sudo apt install ubuntu-desktop
sudo apt install tightvncserver
sudo apt install gnome-panel \
		gnome-settings-daemon \
		metacity \
		nautilus \
		gnome-terminal

Next, run this command (or paste into the file itself if you want) to setup the desktop environment to start when VNC starts.

cat <<EOF > ~/.vnc/xstartup
#!/bin/sh
export XKL_XMODMAP_DISABLE=1
unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS

[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey

vncconfig -iconic &
gnome-panel &
gnome-settings-daemon &
metacity &
nautilus &
gnome-terminal &
EOF

And finally, launch the vnc server, and have it listen on the first virtual console (:0 is reserved for the physically attached console).

vncserver :1

On the Mac: (5901 is default tightvnc port, adjusting as necessary)

ssh ubuntu@hostname -L 5901:localhost:5901

And then CMD+K ‘go to server’ and go to vnc://localhost:5901

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment