This blog describes how I set up a CentOS 6.5 VPS dev host for RDP access using “Microsoft Remote Desktop” from my Mac.
I have a virtual private server (VPS) that was setup as a vanilla server but I wanted to use it for development which means, among other things, that I wanted to access it remotely using a windowing environment. I also wanted to make it easy for my Windows based colleagues to access it which was the motivation for using the remote desktop protocol (RDP).
Remember, this is only for remote development hosts. Do not do this for production or testing servers because it expands the potential attack surface.
These are the basic configuration steps for installing XRDP on the remote server:
- Create one or more users (you do not want to login remotely as root for security).
- Install the base necessary packages.
- Install the EPEL repository and EPEL packages.
- Configure the VNC resolution in /etc/sysconfig/vncservers.
- Configure ~/.vnc/xstartup.
- Configure the services.
- Add additional packages if desired.
- Add additional fonts if desired.
Once it has been configured you access it from your local host as follows.
- Setup up an SSH tunnel from a local socket to the remote server 3389 socket.
- Run an RDP client.
Both configuration and access are described in more detail below.
These are the commands that I used to configure it. The output has been snipped to save space. You will see that the example below shows root logging in remotely contrary to my earlier comment. That was done to simplify the steps. In practice you would probably create a sudo user and disable root logins.
$ # Step 1. Login and create a user
$ ssh firstname.lastname@example.org
$ useradd rdpuser
$ passwd rdpuser # set a password for rdpuser
$ # Step 2. Install the necessary packages
$ # You probably only need Desktop and "X Window System"
$ yum groupinstall -y 'Desktop Platform Development' 'X Window System' 'Desktop'
$ yum install –y wget pciutils mlocate
$ yum update
$ updatedb # update the locate db
$ init 6 # reboot
$ # Step 3. Login again (after the reboot)
$ ssh email@example.com
$ # Step 4. Install the EPEL repository.
$ wget http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
$ rpm -ivh epel-release-6-8.noarch.rpm
$ yum repolist # confirm that the repo was installed
$ # Step 5. Install the EPEL packages.
$ yum install xrdp tigervnc-server
$ # Step 6. Set the VNC/RDP resolution.
$ cat >>/etc/sysconfig/vncservers <<EOF
VNCSERVERARGS="-geometry 1280x1024 -nolisten tcp -localhost"
$ # Step 7. Create the local .vnc/xstartup file.
$ # This needs to be done for each user.
$ su - rdpuser # do this for rdpuser
$ mkdir ~/.vnc
$ cat >~/.vnc/xstartup <<EOF
# Uncomment the following two lines for normal desktop:
[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
$ # Step 8. Configure the services
$ # First configure the iptables to allow traffic on port 3389 so that clipboard
$ # operations work.
$ # CITATION: http://ajmatson.net/wordpress/2014/01/install-xrdp-remote-desktop-to-centos-6-5
$ iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 3389 -j ACCEPT
$ service iptables save
$ service iptables restart
$ # Now start the services.
$ service vncserver start
$ service xrdp start
$ chkconfig xrdp on
$ chkconfig vncserver on
$ # Step 9. Install some useful packages
$ yum install emacs nano vim firefox
$ # Finally – added some fonts to make things more readable.
Once it is configured you can access by setting up an SSH tunnel and then connecting via an RDP client.
Here is how you setup the SSH tunnel.
$ # Create 127.0.0.:12345 tunnel to your server (18.104.22.168).
$ # 3389 is the default RDP socket.
$ ssh -X -A -t -t \
-o port=22 \
-o ServerAliveInterval=300 \
-o ServerAliveCountMax=3 \
-o TcpKeepAlive=no \
-L 12345:127.0.0.1:3389 \
Once the tunnel is running you can access via your RDP client using 127.0.0.1:12345. Here is what it looks like from my Mac using “Microsoft Remote Desktop”.