1) Launch the Ubuntu instance on EC2.
2) Open the SSH Port in the security instance.
3) Make SSH to the instance.
4) Run:
sudo apt-get update sudo apt-get upgrade
5) Since you will be connecting from a remote Windows desktop, edit the sshd_config file in your Linux instance to allow password authentication.
sudo vim /etc/ssh/sshd_config
6) Change PasswordAuthentication to yes with no, then save and exit.
7) Restart the SSH daemon for the changes to take effect.
sudo /etc/init.d/ssh restart
8) Temporarily gain superuser privileges and change the password for the Ubuntu user to a complex password to increase security. Press Enter after entering the passwd ubuntu command, and you will be asked to enter the new password twice.
sudo βi passwd ubuntu
9) Go back to your Ubuntu user account and go to the Ubuntu home directory.
su ubuntu cd
10) Install the functionality of the Ubuntu desktop on your Linux instance, the last command may take up to 15 minutes.
export DEBIAN_FRONTEND=noninteractive sudo -E apt-get update sudo -E apt-get install -y ubuntu-desktop
11) Install xrdp
sudo apt-get install xfce4 sudo apt-get install xfce4 xfce4-goodies
12) Make xfce4 the default window manager for RDP connections.
echo xfce4-session > ~/.xsession
13) Copy .xsession to the / etc / skel folder so that xfce4 is set as the default window manager for all user accounts that are created.
sudo cp /home/ubuntu/.xsession /etc/skel
14) Open the xrdp.ini file to allow changing the host port to which you will connect.
sudo vim /etc/xrdp/xrdp.ini
(xrdp has not yet been installed. Install xrdp first with sudo apt-get install xrdp, then edit the above file)
15) Find the [xrdp1] section and change the following text (then save and exit [: wq]).
port=-1 - to - port=ask-1
16) Restart xrdp.
sudo service xrdp restart
17) On Windows, open the Remote Desktop Connection client, paste in the full name of your Amazon EC2 instance for the computer, and click Connect.
18) When prompted to log in to xrdp, make sure the sesman-Xvnc module is selected and enter the ubuntu username with the new password that you created in step 8. When you start the session, the port number is -1.
19) When the system is connected, several status messages are displayed on the connection log screen. Pay particular attention to these status messages and write down the VNC port number. If you want to return to the session later, specify this number in the port field of the xrdp login dialog box.
For more details see: https://aws.amazon.com/premiumsupport/knowledge-center/connect-to-linux-desktop-from-windows/
http://c-nergy.be/blog/?p=5305