RDP from Ubuntu into AWS Ubuntu

Simple way to get RDP into Ubuntu AWS box:

  • Create the instance in the EC2 Management console and enable incoming RDP in Security Groups
  • Create a new user with a password
  • Add the new user to the sudoers file and copy over the AWS server’s public key
  • Log in as the new user and install xrdp
  • Load Remmina on your local machine and open a new RDP connection

Notes

In EC2 Management Console, click on the instance you want to connect to and scroll the page to the right. There will be a URL link to the relevant Security Group configuration page. Click on the Inbound tab and then the Edit button. Add a new rule, look for RDP as the type and set anywhere as the source (or make it specific if you want).

Move to the Terminal on your local machine and login to your AWS server with a command similar to:

LocalMachine:$ ssh -i ~/AWS-keypair.pem ubuntu@ec2-some-id.amazonaws.com

Create new user e.g. george

AWSMachine:$ sudo adduser george

Follow the prompts to enter the password and other optional user information. Add the new user to the sudoers file using the visudo command:

AWSMachine:$ sudo visudo

Add the following line after the comment line, “User privilege specification” and save the file.

george   ALL=(ALL:ALL) ALL

Ensure that the user george is in the sudo groupusing:

AWSMachine:$ sudo adduser george sudo

The new user account cannot be accessed (e.g. via SSH) until the public key from the AWS instance’s key pair (the .pem file) is installed for the new user. To do this, copy the public key installed for the ubuntu user and paste it into the correct file in the new user account. The public key can be found in the file ~/.ssh/authorized_keys under the ubuntu account.

AWSMachine:$ cat ~/.ssh/authorized_keys

SThe command above will print the public key. Select everything apart from the name of the key pair at the end of the key and copy it.

Next, switch to the new user account, george, and make sure you are in the home directory.

AWSMachine:$ sudo su george

Create the SSH directory and authorised users file, with the correct permissions in the home directory. Then edit the authorized_keys file with a text editor.

AWSMachine@george:$ mkdir .ssh
AWSMachine@george:$ chmod 700 .ssh
AWSMachine@george:$ touch .ssh/authorized_keys
AWSMachine@george:$ chmod 600 .ssh/authorized_keys
AWSMachine@george:$ nano .ssh/authorized_keys

Paste in the public key you previously copied and save the file, before exiting the system.

AWSMachine@george:$ exit
AWSMachine:$ exit

You should now be able to log into the new user george on the remote Amazon AWS server using the same keypair. On your local machine, use the SSH command:

LocalMachine:$ ssh -i ~/AWS-keypair.pem george@ec2-some-id.amazonaws.com

We now are logged in as user george.

Install the lxde lightweight desktop manager and start it.

 sudo apt-get update 
 sudo apt-get install lxde
 sudo start lxdm

Also install xrdp to establish a remote desktop connection.

 sudo apt-get install xrdp

Remote desktop connections require a username and password. The username will be george and the password will be the one set when the user was created. If you forget this the password can be reset using:

 sudo passwd ubuntu
In Remmina, create a new connection and paste in the public DNS of the AWS box (ec2-some-id.amazonaws.com) into the Server box. Set the user as george, make sure the protocol is RDP and set the Colour Depth as True Colour 32-bit. Save and Connect.


None of this would be known without the notes and guidance from others on the web, namely:

http://www.brianlinkletter.com/how-to-set-up-a-new-userid-on-your-amazon-aws-server-instance/

http://comtechies.com/how-to-set-up-gui-on-amazon-ec2-ubuntu-server.html

https://serverfault.com/questions/776391/unable-to-remote-connect-from-windows-to-ubuntu-desktop-using-ec2

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

A WordPress.com Website.

Up ↑

%d bloggers like this: