How to enable Desktop Experience and enable RDP for a CentOs 7 VM on Microsoft Azure

[bing_translator]Normally when you provision a Linux VM on Microsoft Azure, it's provisioned for you on the CLI mode which most of the Linux fans are fund of it but in case you would like to use the desktop experience and RDP to the machine instead of SSH to it, you will need to follow these simple steps.

Connect to the VM using the SSH command tool like Putty.exe

In the upper putty window you can see that I'm connecting to this "VM centosrdp.cloudapp.net" on port 22 which is the default port of ssh, you will need to replace the value of the Host Name and Port with your own, to get this on Microsoft Azure , you will need to navigate to your machine's dashboard on the management portal on Azure, check the screenshot below and obtain the DNS name highlighted below.

After Connecting to the VM on the CLI, you will get prompted to enter your username and password, so go ahead and enter the same username and password you created to access your VM on Azure.

and then run this command to gain root privileges.

 # sudo -s

Install EPEL and nux Desktop repository rpms.

 # rpm -Uvh http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-1.el7.nux.noarch.rpm

after this is successful, continue by installing the GNOME desktop to get the graphical user interface you desire

 # yum groupinstall "GNOME Desktop" "Graphical Administration Tools"

the installation process will take sometime depending on your internet speed, after the installation is done, run the following command to change the reboot from CLI to GUI.

 # ln -sf /lib/systemd/system/runlevel5.target /etc/systemd/system/default.target

the next step is to install the xrdp to be able to RDP on the VM

 # yum -y install xrdp tigervnc-server

then start the xrdp service

 # systemctl start xrdp.service

then test the xrdp service by running the following command, you should see the next screenshot

 # netstat -antup | grep xrdp

now you can enable the xrdp service

 # systemctl enable xrdp.service

And then add a port in the machine firewall if it was activated, if not then there is no need for the next two commands.

 # firewall-cmd --permanent --zone=public --add-port=3389/tcp
# firewall-cmd --reload

Now that we have configured the CentOs 7 VM to have GUI and we have enabled the xrdp service on it, we have only one step left which is only adding an endpoint to the machine on Azure management portal. Go back to the Azure management portal and go to your VM ENDPOINTS Tab, check the screenshot below and then Add a new endpoint by clicking the Addbutton in the task bar on the lower end of the portal.

After clicking on the Add button, you will have the following form where you select from it RDP and choose keep the default values of the port and then click Ok , this will create a RDP endpoint where you can connect successfully to the machine, after the creation is done, you will see a new record added under your ENDPOINTS This is the view after the creation of the endpoint is succeeded

Now you can test the connection to your VM by clicking on connect button in the VM's dashboard task bar

which will download the RDP file to connect to this VM, click connect on it and then you will see this notification which you will have to click Ok

then the RDP window will open with the following screenshot

Enter your credentials here and then you will see the following prompt windows and viola you did it :)