Created
May 12, 2015 22:15
-
-
Save shortdudey123/841467acb6271c8bb103 to your computer and use it in GitHub Desktop.
Add desktop and VNC to Ubuntu on AWS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Created by: Grant Ridder <[email protected]> | |
# Instructions taken from the below link unless noted | |
# http://stackoverflow.com/questions/25657596/how-to-set-up-gui-on-amazon-ec2-ubuntu-server | |
# SET THESE VARIABLES TO YOUR OWN!!! | |
# begin | |
VNC_PASSWORD="<password up to 8 char long>" | |
SSH_KEY="</path/to/your/ec2/ssh/key.pem>" | |
# end | |
sudo apt-get update | |
echo "lightdm shared/default-x-display-manager select lightdm" | sudo debconf-set-selections | |
sudo apt-get install ubuntu-desktop -y | |
sudo apt-get install ubuntu-desktop -y # some stuff fails dependencies the first run | |
# debconf settings from https://bugs.launchpad.net/ubuntu/+source/gdm/+bug/1020770 | |
echo "debconf debconf/priority select critical | |
gdm shared/default-x-display-manager select lightdm" | sudo debconf-set-selections | |
sudo apt-get install vnc4server expect gnome-core gnome-session-fallback -y | |
prog=/usr/bin/vncpasswd | |
/usr/bin/expect <<EOF | |
spawn "$prog" | |
expect "Password:" | |
send "$VNC_PASSWORD\r" | |
expect "Verify:" | |
send "$VNC_PASSWORD\r" | |
expect eof | |
exit | |
EOF | |
vncserver | |
vncserver -kill :1 | |
rm ~/.vnc/xstartup | |
cat <<EOT >> ~/.vnc/xstartup | |
#!/bin/sh | |
# Uncomment the following two lines for normal desktop: | |
#unset SESSION_MANAGER | |
#exec /etc/X11/xinit/xinitrc | |
# gnome session workaround | |
# http://broderick-tech.com/vncxstartup-files-ubuntu-14-04/ | |
export XKL_XMODMAP_DISABLE=1 | |
unset SESSION_MANAGER | |
unset DBUS_SESSION_BUS_ADDRESS | |
gnome-panel & | |
gnome-settings-daemon & | |
metacity & | |
nautilus & | |
gnome-terminal & | |
[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup | |
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources | |
xsetroot -solid grey | |
vncconfig -iconic & | |
#x-terminal-emulator -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" & | |
#x-window-manager & | |
EOT | |
chmod 755 .vnc/xstartup | |
vncserver | |
PUBLIC_IP=$(curl http://169.254.169.254/latest/meta-data/public-ipv4) | |
echo "~~~~~~~~~~~~~~~~~~~~~~~~~ VNC ~~~~~~~~~~~~~~~~~~~~~~~~~" | |
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" | |
echo "" | |
echo "Public IP: $PUBLIC_IP" | |
echo "" | |
echo "To VNC in:" | |
echo -e "\tssh -L 5902:localhost:5901 ubuntu@$PUBLIC_IP -i $SSH_KEY -o StrictHostKeyChecking=no" | |
echo -e "\tConnect to: vnc://localhost:5902" | |
echo -e "\tPassword: $VNC_PASSWORD" | |
echo "" | |
echo "" | |
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" | |
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment