How To Connect To AWS EC2 Ubuntu GUI Using PUTTY From The Windows Machine?

This article includes the steps of creating an Amazon AWS Ubuntu instance, setting up a desktop GUI via PUTTY, and connecting to it via Remote Desktop Connection.

So let’s get started,

We will start by creating an EC2 instance. Go to EC2 Console https://console.aws.amazon.com/ec2/v2/home and Click on Launch instance. Where you will find multiple AMIs, Scroll down and select Ubuntu Server (For testing purpose select Free tier eligible).

Create-EC2Once you select the server, follow further steps, and launch. Make sure while launching download the PEM file as it will need in the future.

Now go to the EC2 dashboard and look for a public IP address and Copy that as we will need for PUTTY configuration, Though you can use Public DNS as well.

EC2-1

We are done with AWS configuration, now open PUTTY and follow a few steps:

  • Add copied IP address in the Host Name field and name the Saved session and save it. Will keep port as it is i.e., 22 as we have only opened the 22 port as we want everything should go through the SSH tunnel; though you can open other ports as well there will be less security.

Connect To AWS EC2 Ubuntu GUI Using PUTTY

Check Out What It Takes To Build A Successful App Here

  • Add SSH (PPK) key by browsing SSH -> Auth -> Private Key file for authentication -> Browse and again go to Session and Save it.
    Note: By default, AWS only provide a PEM file. We need to convert PEM to PPK. You can find multiple online tools for converting this.

Connect To AWS EC2 Ubuntu GUI Using PUTTY

  • Click on Open, and it will prompt a security alert just choose Yes, and you will able to see the command prompt.
    On the command prompt, just log in as Ubuntu, as we have added PPK so it won’t ask for Password.

Connect To AWS EC2 Ubuntu GUI Using PUTTY

  • Once you get logged into the server, you need to follow the below.
    • sudo apt update && sudo apt upgrade
    • sudo sed -i ‘s/^PasswordAuthentication no/PasswordAuthentication yes/’ /etc/ssh/sshd_config – To set login credentials
    • sudo /etc/init.d/ssh restart
    • sudo passwd ubuntu – This will be your login password to ubuntu machine
    • sudo apt install xrdp xfce4 xfce4-goodies tightvncserver
    • echo xfce4-session> /home/ubuntu/.xsession
    • sudo cp /home/ubuntu/.xsession /etc/skel
    • sudo sed -i ‘0,/-1/s//ask-1/’ /etc/xrdp/xrdp.ini
    • sudo service xrdp restart

Note: In between, if this process asks for some kind of choice, then select the local version installed option.

Now, we need to configure the tunnel on PUTTY to the route of the request.

Open PUTTY again and go to the Connection – > SSH -> Tunnels ->

  1. Add Source Port (This could be any in my case I have added 8888).
  2. Add Destination Port – This will be your instance private IP address following with 3389.
  3. Click on Add.

Connect To AWS EC2 Ubuntu GUI Using PUTTY

We Build HIPPA Complaint Telehealth Platform Using AWS Cloud

Once done, now click on the open button and you will see a Command prompt where login Id will be Ubuntu.
Now you can check either we are listening on the same port or not using the following command: netstat -antp

Connect To AWS EC2 Ubuntu GUI Using PUTTY

Now we are done with the setup.

Open Remote Desktop Connection

Add localhost:8888 or 127.0.0.1:8888 and Connect

Connect To AWS EC2 Ubuntu GUI Using PUTTY

You will be asked for a username and password; So username could be Ubuntu and Password will be added by you while installing the command. And Yeah, there you go, We have successfully logged into the Remote server.

coma

Conclusion

In this way can learn, steps of creating an Amazon AWS Ubuntu instance, setting up a desktop GUI via PUTTY, and connecting to it via Remote Desktop Connection. If You have any doubts regarding this article please comment us.

Get a team of Full Stack Developers started within 24 hours

Keep Reading

Keep Reading

  • Service
  • Career
  • Let's create something together!

  • We’re looking for the best. Are you in?