Jan 12, 2015

How to Remote Desktop (RDP) Linux Machine from windows 7


Overview
Our requirement is to enable remote desktop function in centos Linux machine which will allow us to access Linux box from windows machine using mstsc.exe (Remote Desktop).

For that we will use XRDP which is wonderful remote desktop protocol application. It is free open source software for Linux.

Installation:
We need some additional work to install XRDP on centos as centos repositories do not contain the XRDP package. You need to download and add EPEL (Extra Packages Enterprise Linux).

Let’s verify our correct OS architecture first.
Using below command we can verify OS architecture.

Step 1:
[/root]# uname -r
2.6.32-431.el6.x86_64

If the output shows x86_64 at end then mean, you have a 64-bit install or if it shows i386 then it is a 32-bit install.

Our output is showing (2.6.32-431.el6.x86_64) it’s mean we have 64-bit operating system.
After determining your architecture, install the correct EPEL repository with below command.

Step 3:
For RedHat or Centos 6.x 32-bit
[/root]# wget http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
[/root]# rpm -ivh epel-release-6-8.noarch.rpm

For Redhat Enterprise Linux or Centos 5.x 64-bit
[/root]# wget http://dl.fedoraproject.org/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm
[/root]# sudo rpm -Uvh epel-release-5*.rpm

For RedHat Enterprise Linux or Centos 6.x 64-bit
[/root]# wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
[/root]# sudo rpm -Uvh epel-release-6*.rpm

For Redhat Enterprise Linux or Centos 7.x 64-bit
[/root]# wget http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-1.noarch.rpm
[/root]# sudo rpm -Uvh epel-release-7*.rpm

Step 4:
Lets verify EPEL repository is installed correctly
[/root]# yum repolist -v | grep epel
We can see EPEL repository is installed correctly.

While doing this step, if any following error occurs,

"Loaded plugins: fastestmirror, refresh-packagekit, security Loading
mirror speeds from cached hostfile
Error: Cannot retrieve metalink for repository: epel. Please verify its path and try again"

Solve this issue editing both /etc/yum.repos.d/epel.repo and /etc/yum.repos.d/epel-testing.repo files, commenting all entries starting with mirrorlist=... and uncomenting all the entries starting with baseurl=...

If it didn’t solve the issue, then run yum update on the os.

Step 5:
Now we need to install XRDP package including some dependencies.
[/root]# yum install xrdp tigervnc-server

Step 6:
After instllation we need to configure display.

Edit display file located at /etc/sysconfig/vncservers
[/root]# vim /etc/sysconfig/vncservers

Find at last these lines
# VNCSERVERS="2:myusername"
# VNCSERVERARGS[2]="-geometry 800x600 -nolisten tcp -localhost"

Uncomment and change them into.
VNCSERVERS="2:root"
VNCSERVERARGS[2]="-geometry 800x600"

I am using root user as my remote desktop user.
Now save this file and exit.

Step 7:
Start VNC and XRDP services.
[/root]# service vncserver start
[/root]# service xrdp start

If any following error occurs on vncserver start,

"You will require a password to access your desktops.
getpassword error: Inappropriate ioctl for device"

Run the command "vncserver /.vnc/passwd" and then enter the password (i.e. Setup new password)


Step 8:
Make them available on next startup.
[/root]# chkconfig xrdp on
[/root]# chkconfig vncserver on

That’s it all the packages are installed, now you should be able to access your linux box from any RDP Client.

Stop iptables from centos machine.
[/root]# sudo /etc/init.d/iptables stop 


Then goto your windows machine where you need to connect the above configured Linux machine. Click on "Start" and type "mstsc.exe".

In the open dialog, enter the Linux PC's ip address & Enter. Give Linux machine's user name ('root' in our case) and password.

Now you are connected to Linux via Remote Desktop.

1 comment: