Step by step setting up Ubuntu on AWS and connecting to GUI with MS Remote Desktop Connection on a windows computer
- Windows Computer (mine is windows 7)
- Remote Desktop Connection (come with windows)
- AWS account (link below to register)
- PuTTY (link below to download)
Link: https://aws.amazon.com/
-
sign in to the console
-
On the right side where all different type of OSs are listed, select Ubuntu Server 16.04 LTS (HVM), SSD Volume Type.
The reason why I choose this version is that MS Remote Desktop Connection works on this version and I don't want to figure out if the same method work for the other version (Ubuntu Server 18.04 LTS (HVM), SSD Volume Type). -
Click Review and Launch if you want the free version. Nothing for you to set up.
-
Again in the next page, click launch
-
Now you are promoted with Selecting a new key pair. It is like username and password combination for your VM at AWS.
If you never created VM at AWS before, you won't have any existing key pair. So select create a new key pair.
Name it however you want - Mine is CallMeMaybe~~~
Click Download Key Pair and you will get a file "whatever you named it".pem;
This is the love of your life and you should keep it save and never delete it
-
Click Launch Instance
Your Instances are now launching; scroll all the way down, you will see View Instance at the bottom right corner -
Click View Instance and you will see something like the picture below:
Important things includes but not limited to the following: -
Now you are done with Ubuntu set up. We now need a tool to connect to our VM - PuTTY
- Go to: https://www.putty.org/
- Click Download PuTTY
- Download whichever bit apply to you. Mine is 64-bit.
-
Following the Installation instruction. There is nothing to set up...
-
Once your PuTTY is installed, go to start menu:
- All Programs
- PuTTY Folder
- PuTTYgen and you will get the following program:
- The program is used to load the Key Pair(CallMeMaybe.pem as I generated in step 6) and generate private key
- Click Load
- Navigate to the folder where you saved your Key Pair. You will not be able to see the Key Pair because the file selection is default to PuTTY Private Key Files(.ppk). Change to All Files and you will see your AWS Key Pair
- If you see the above picture, Key Pair is loaded.
- Now you need to set password(passphrase) for your private key
- Select RSA as the type of Key to generate
- Number of bits in a generated key: 2048
- save Private Key (CallMeMaybe.ppk)
- exit PuTTYgen
- Now let's connect to your AWS Ubuntu through PuTTY
- At the PuTTY landing Page (Session tab on the left menu), we need to fill out the following information (Go to Step 8 to find the information)
- a. Host Name (or IP Address) - IPv4 public IP from the AWS Console Instance Page
- b. Port 22 (Default)
- c. Connection Type SSH (Default)
- d. DO NOT load yet, we are not done
- On the left side menu, click Connection -> SSH -> Auth
- Now you land on the Options controlling SSH authentication page
- I kept all the default selection (see picture below)
- click Browse
- loack CallMeMaybe.PPK file (It's the PPK file generated by the PuTTYgen, not the pem file you download from AWS)!!!!
- DO NOT Click Open!!!
-
Now we navigate back to the Session page - > Name the session(CallMeMaybe Instance) -> Save -> and you will see the name appear inside the Saved Session box. Now click Open. See picture below:
-
This is the first time you connect to the VM through PuTTY, you will get a scary msg like the picture below. Just ignore it and click Yes :D
-
Now you are in the DOS where we need to login to our Ubuntu System. User Name: ubuntu Password: whatever password you set up for the private key - see step 13
- Following the above step, you are login to the system. We need to check for Update; Type or copy the following to the DOC (please include "sudo", it's part of the cm...
sudo apt update && sudo apt upgrade
You will be promoted to install more in the additional disk(see below picture). Type Y.
You will see the following page.. Select "Keep the local version currenly installed" - press enter
- Once you are done, let's config sshd_config file to allow password authentication on our ubuntu
sudo sed -i 's/PasswordAuthentication no/PasswordAuthentication yes/' /etc/ssh/sshd_config
- We need to restart the SSH daemon for the new sshd config to take effect
sudo /etc/init.d/ssh restart
- Get temporarry root privileges and change the password more security
sudo passwd ubuntu
Enter another password.. please dont forget it. you will need it to log in to the system.
- Install the xfce4 desktop environment - xrdp
sudo apt install xrdp xfce4 xfce4-goodies tightvncserver
It will ask you if you want to continue. I typed Y too fast and forgot to screenshot.. Just type Y and wait for it to install
- set xfce4 as the default manager for RDP connections
echo xfce4-session> /home/ubuntu/.xsession
- Copy .xsession to the /etc/skel folder and Run the sed command to update the [xrdp1] section
sudo cp /home/ubuntu/.xsession /etc/skel
sudo sed -i '0,/-1/s//ask-1/' /etc/xrdp/xrdp.ini
- Restart xrdp
sudo service xrdp restart
- Now you are almost done! We now need to roboot the system.
sudo roboot
- We need to go back and config PuTTY again
- On the left side Menu, select Connection -> SSH ->Tunnel and we need to do the following:
- Source port: can be anything as long as they are not in conflict. we use 8888 here
- Destination: It is the Private IPs from your AWS Ubuntu Instance + ":3389" (Dont forget the semicolon )
- See picture below for a more clear view
-
Go back to Session page, click Save so next time you dont have to config again.
-
Click Open and login
-
Type in the following code to see if the port is connected
netstat -antp
-
If you find 0.0.0.0:3389, then you are connected. Now we can work on the Remote Desktop Connection
-
Launch Remote Desktop Connection and type in the computer field; 8888 is the port number you set in the above step(step 11). If you set a different number, you should go back and check what the number
127.0.0.1:8888
-
Click Connect and Remote Desktop Connection will launch. Now type in username and password username: ubuntu password: Same Password you set in Step 4
-
Now lets get you a browser
- click Application
- click Terminal Emulator
- Type in the following code
sudo apt-get install firefox