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


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 🙂

Comments (16)

  1. Bothwell says:

    many thanks for this, mine is working.

    I would like to ask on how secure the xrdp session is.

    I read here http://xrdp.sourceforge.net/documents/security/ we should create a rsakeys.ini , would you know if this is still necessary or maybe assist on how to do it

    1. k.moussa says:

      Thanks Bothwell, for securing access via xrdp session, try this blog post http://c-nergy.be/blog/?p=6020

  2. Muralidas says:

    I flowed the same link but I am getting blank screen only after login.

    1. k.moussa says:

      Hi Muralidas,

      Just to make sure I got your point, you followed all the steps in the article and you are able to RDP to your linux VM and after you login with your credentials,it gives you a blank screen ? is this what happens ?

  3. Daniel Balaguera says:

    Hello,

    I follow this steps and it works

  4. Nicholas says:

    Thank you k.moussa.

  5. Andrew says:

    I'm trying to do this for a non-classic vm (resource manager). I installed xrdp and created an inbound rule for port 3389, but when I try to rdp it fails. Id there something I'm missing?

    Thanks.

    1. Alberto says:

      For resource manager VMs you can create an inbound rule for RDP in the Network Security Group.

    2. k.moussa says:

      Hi Andrew, sorry for replying that late – was on a long business trip, are you able to reach the machine on the public IP or it rejects the connection?

  6. Subhash says:

    I am able to connect the VM via RDP. But after I entered the username/pwd while creating the VM…I was prompted to enter password for the user "Administrator" (to create color managed device). What is the default password ? I never set any username "Administrator while creating.

  7. PJ Gorman says:

    Absolutely fantastic article!

    Begs the question: Why did i have to search Google to find this great msdn article after spending over half an hour poking around in the azure linux VM tutorials.

  8. David Stephenson says:

    Outstanding article!   Got me up and running in less that 15 minutes.  Thank you kmossa

  9. Takashi Uesaka says:

    I had same problem with Gaurav.I checked the status about xrdp by : systemcrl | grep xrdp, the status was faild.

    I used followed command.

    chcon -t bin_t /usr/sbin/xrdp

    chcon -t bin_t /usr/sbin/xrdp-sesman

    and restart xrdp.

    systemctl restart xrdp.service

    Then I suceeded to connecting the VM.

  10. Gaurav says:

    hi ,

    I followed the steps . all the steps worked except this one : netstat -antup | grep xrdp .

    I did not get any statements which you mentioned in the image .

    Secondly I am able to use Remote desktop for connecting the VM . Its showing the same error message. Can you suggest something ?

    Thanks

    Gaurav

  11. David R Sachs says:

    I was able to follow the exact instructions above and reproduce Karishma's error "Oh no! Something has gone wrong…"

    I was able to get to the desktop after troubleshooting. I had a number of suspect causes, but I believe the fix was one (or both) of the following:

    1) sudo yum update

    2) sudo adduser <username>

    sudo passwd <username>

    (assign password for newly created user)

    …I connected to my host via (x)RDP with the new user creds I had created. The desktop session connection was successful.

    (Note: I have not used the desktop extensively yet.)

  12. Karishma says:

    Hi k.moussa,

    I followed the exact steps and login to rdp, but i get a screen with a sad pc image saying:

    _____________

    Oh no! Something has gone wrong.

    A problem has occurred and the system can't recover.

    Please log out and try again.

    _____________

    What is missing here?

Skip to main content