AWS EC2 Ubuntu Instance VNC access
In this post I'll write about how to connect to your EC2 Ubuntu linux instance via VNC Viewer app. Let's get started......
Kindly login to your AWS instance via private key through terminal/putty as shown below and follow the steps from 1 to 8 to access your Ubuntu (18.x in my case) GUI from your local machine-
ssh -i your-aws-key.pem ubuntu@ec2-x-x-x-80.ap-south-1.compute.amazonaws.com
Step-1
sudo apt update && sudo apt upgrade
Step-2
sudo apt-get install ubuntu-desktop gnome-panel gnome-settings-daemon metacity nautilus gnome-terminal xfce4 vnc4server
Step-3
vncserver
Enter the password- xxxx
Confirm Password- xxxx
Step-4
vi ~/.vnc/xstartup
Uncomment previous and use this one in xstartup file as shown below
#!/bin/sh
# Uncomment the following two lines for normal desktop:
unset SESSION_MANAGER
# exec /etc/X11/xinit/xinitrc
unset DBUS_SESSION_BUS_ADDRESS
startxfce4 &
[ -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
Step-5
Kill VNC session. It was the first session so the display ID would be 1.
vncserver -kill :<DISPLAY_ID>
vncserver -kill :1
Step-6
Optionally reboot your VM
Step-7
vncserver -geomeory 1340x750
<Provide VNC Password>
UPDATE: in case of error occurs due to -geometry parameter, start directly as-
vncserver
Step-8
Open SSH terminal/ putty and enter below command to connect to your EC2 instance
ssh -L 5901:localhost:5901 -i your-aws-key.pem ubuntu@ec2-x-x-x-80.ap-south-1.compute.amazonaws.com
Make sure your was key file is at same location from where you execute command or provide absolute path to your key file in above line. So your-aws-key.pem will be /..path/your-aws-key.pem like location
Step-9
Now Open VNC Viewer App and enter the VNC password in prompt window.
Press Ok and now you are connected to your Ubuntu Vm instance in GUI mode
Step-8
Open SSH terminal/ putty and enter below command to connect to your EC2 instance
ssh -L 5901:localhost:5901 -i your-aws-key.pem ubuntu@ec2-x-x-x-80.ap-south-1.compute.amazonaws.com
Make sure your was key file is at same location from where you execute command or provide absolute path to your key file in above line. So your-aws-key.pem will be /..path/your-aws-key.pem like location
Step-9
Now Open VNC Viewer App and enter the VNC password in prompt window.
Press Ok and now you are connected to your Ubuntu Vm instance in GUI mode
That's it. Your Ubuntu Linux VM GUI is ready to use.
Thanks for reading this post :)
ReplyDeleteVery nice post with lots of information. Thanks for sharing this
Workday Online Training
Workday Online Training Hyderabad
great instructions.
ReplyDeleteNice Post. I like your blog. Thanks for Sharing.
ReplyDeleteDevOps Training
DevOps Online Training
I enjoyed your blog Thanks for sharing such an informative post. We are providing the best services click on below links to visit our website.
ReplyDeleteOracle Fusion HCM Training
Workday Training
Okta Training
Palo Alto Training
Adobe Analytics Training