Amazon Elastic Cloud Compute is a service provided by amazon for performing computing operations by the users. We often create an ec2 instance for various requirements. Most of which are solved by accessing the instance via ssh. This enables you to get a CLI mode of interaction with your instance. It is suitable for most of your workloads, but sometimes it becomes necessary to have the GUI interaction with your instance.
Lets check out a way to access GUI of AWS EC2 instance of Ubuntu.
Go to ec2 console in AWS
Click on Launch Instances
The following window will be displayed.
Search for Ubuntu Instance and select the Ubuntu Server 20.04 LTS
Choose an instance type
I have chosen t2.micro as it is eligible in Free-tier.
Leave the conf settings as it is or do some changes if you require.
I will go with the default settings in storage as well.
In Add Tags section, you can specify the tags that you want to associate with your instance. Here, I have specified a Name tag.
In the Configure Security Group settings, check for the existing rules
To add on security, you can specify the source with your ip, so that only you can ssh into that instance.
Click on Review and Launch. Check everything and click on Launch
A pop-up will emerge. If you have an existing key-pair, use that one or feel free to create a new key-pair
In Launch Status window, click on View Instances
Your newly created instance will be visible here, as shown below.
Click on Connect
Click on SSH client
Once all the instance is up and running, we continue with the following steps.
ssh into the instance
Now once, you are logged into your instance. Run the following commands
sudo apt update && sudo apt upgrade
On prompting, type Y and press Enter
sudo sed -i 's/^PasswordAuthentication no/PasswordAuthentication yes/' /etc/ssh/sshd_config
Restart the service:
sudo /etc/init.d/ssh restart
sudo passwd ubuntu
sudo apt install xrdp xfce4 xfce4-goodies tightvncserver
On prompt, type Y and press Enter
echo xfce4-session> /home/ubuntu/.xsession
sudo cp /home/ubuntu/.xsession /etc/skel
sudo sed -i ‘0,/-1/s//ask-1/’ /etc/xr
Restart the service
sudo service xrdp restart
Sudo apt-get install putty
Now, copy the public ip of your instance
Open Putty and paste the public ip in hostname
Copy the private ip of the instance
Add the source port to 8888 and click on Add.
Go to Auth.
Click on Browse
Search for the pem file
Click on Open
Click on Accept
Enter the login information
Now go to RDP
Click on New Connection Profile.
This window will open
Type username and password.
Click on OK
The following window will be displayed
Hey Readers, thank you for sticking up till the end. I hope this blog was informative and helped you in logging in the Ubuntu instance of EC2. Still, if you have any doubts, please feel free to drop your questions/suggestions in firstname.lastname@example.org.