Skip to content

Instantly share code, notes, and snippets.

@arschles
Last active October 4, 2019 00:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arschles/ca0ae6d6d4d397875397223b83ec21c3 to your computer and use it in GitHub Desktop.
Save arschles/ca0ae6d6d4d397875397223b83ec21c3 to your computer and use it in GitHub Desktop.
Set up Gnome and VNC server on an Azure Ubuntu Server VM
#!/bin/bash
set pipefail
set -eou
apt install gnome-core ubuntu-gnome-desktop
echo "Now go and click 'reboot' on your VM in the portal"
#!/bin/bash
# inspired by:
# https://medium.com/@achekulaev/how-to-set-up-linux-desktop-environment-in-the-cloud-with-digitalocean-droplet-e51ae4e066b
set pipefail
set -eou
# 1. Installing XFCE and VNC server
apt update
apt install xfce4 xfce4-goodies tightvncserver xfonts-base x11-xserver-utils
#!/bin/bash
# inspired by:
# https://medium.com/@achekulaev/how-to-set-up-linux-desktop-environment-in-the-cloud-with-digitalocean-droplet-e51ae4e066b
set pipefail
set -eou
vncserver
# inspired by https://superuser.com/a/392263/140872
DISPLAY=:1 xhost +
vncserver -kill :1
mv ~/.vnc/xstartup ~/.vnc/xstartup.bak
cat << EOF > ~/.vnc/xstartup
#!/bin/bash
xrdb $HOME/.Xresources
startxfce4 &
EOF
chmod +x ~/.vnc/xstartup
#!/bin/bash
# inspired by:
# https://medium.com/@achekulaev/how-to-set-up-linux-desktop-environment-in-the-cloud-with-digitalocean-droplet-e51ae4e066b
set pipefail
set -eou
echo "Make sure you have set your USERNAME env var before running this!"
mkdir -p /home/$USERNAME/.vnc
cp ~/.vnc/xstartup /home/$USERNAME/.vnc/
chown -R $USERNAME:$USERNAME /home/$USERNAME/.vnc/
echo "Need to set up a new password before we can continue:"
passwd
echo "This might error out, but you can ignore that!"
su $USERNAME -c "vncserver -kill :1" || true
su $USERNAME -c "vncserver -depth 24 -geometry 1280x800"
echo "You can now connect to this server on port 5901. Make sure you set up a port rule to allow that port on your VM!"
# This is how to shut down the server
# su $USERNAME -c "vncserver -kill :1"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment