I spent a Saturday morning trying to connect to an AWS EC2 desktop after trying to follow the instructions given by AWS on Connecting to Ubuntu Desktop with Windows that completely failed.
The instructions described here are derived from the following YouTube Video. There were some parts that were not clear/correct so I have clarified and corrected them in this post.
Configure Ubuntu Desktop Server
- Connect ssh to ec2 instance using PUTTY.
- See How to Connect to AWS EC2 using Putty. (I used this method and it works just fine)
- Become the super user by executing the command
- Update the operating system
sudo apt update && sudo apt upgrade
- Type the following commands to install vncserver:
sudo apt-get install ubuntu-desktop
sudo apt-get install vnc4server
sudo apt-get install gnome-panel
- Start the VNCServer.
- Remember the password you set. You will need this passcode later when you connect using tightvnc .
- Kill vncserver
vncserver -kill :1
- Modify the VNC startup script
- Add the following lines to the .vnc/xstartup script
#!/bin/sh # Uncomment the following two lines for normal desktop: unset SESSION_MANAGER # exec /etc/X11/xinit/xinitrc gnome-session –session=gnome-classic & gnome-panel&
- Press ESC, followed by
:wq(write-quit) to save and exit the file
- Start the VNCServer again
Configure your Windows Box
Configure your EC2 Instance
- Edit your security group.
- Add port number 5901 in your ec2 security group
- Write your public ip number (or DNS name) in remote host text box and port number
- Your desktop in ec2 instance is ready and execute the command vncserver after every restart.
- Can I stop my machine and restart it?: Yes. However you will have to re-run the
vncservercommand after restarting the server.