With Xrdp you can remotely log in on a virtual machine, giving you a full virtual desktop. Moreover, you can close the RDP window and pick up the session later, allowing you to continue to work on a graphical desktop while switching off your own local computer.
First, you need to set up your Linux VM, using the following steps.
You will have to type in the user’s password (by default, the same as the user name). Then type in a new password, repeat that when asked, and you are in a terminal on the remote VM.
sudo apt update && sudo apt install -y xorgxrdp xrdp xfce4 tango-icon-theme
sudo sed -i.bak '/fi/a #xrdp multiple users configuration \n xfce-session \n' /etc/xrdp/startwm.sh
sudo ufw allow 3389/tcp
sudo reboot now
After these steps, you should now be able to use your Remote Desktop client from your laptop to connect to the graphical environment. If, after logging in through the Remote Desktop client you are asked to choose a session type, the default “Xorg” should be fine.
The default Unity desktop does not support remote sessions as well as other desktop environments do. To create a virtual machine with a GUI, create a plain server VM and install the desktop environment of your choice, for example KDE or Xfce (which is used in the example below). This following example works under Ubuntu 14.04 server.
sudo su -
ufw allow 3389 ufw allow ssh ufw enable
USERNAME=maarten adduser $USERNAME adduser $USERNAME sudo sudo usermod -aG sudo,adm $USERNAME
sudo apt-get install xrdp xubuntu-desktop tightvncserver apt-get update
echo xfce4-session >~/.xsession
sudo service xrdp restart
Now you can connect to your machine. However, Ubuntu’s default settings are to create a new session each time you log in instead of resuming your old session. Let us fix this.
In the next step you will have to edit a file by using a text editor. For example, you can use
sudo nano /etc/xrdp/xrdp.inito edit the file we will tell you in a moment. To save the changes you can then press the key combination
Ctrl + X(see then that at the bottom of the screen you get a question like Save modified buffer […]?. Press then the
ykey, and finally hit
/etc/xrdp/xrdp.iniand change the items under the
[xrdp1] name=reconnect lib=libvnc.so username=ask password=ask ip=127.0.0.1 port=ask5910
-1for the first session and start your virtual desktop.
5910(default value) and you will continue the previous session.
The following commands open port 3389 for the whole Internet. We strongly recommend that you limit this to a well-known location of yours, such as your Universitie’s network and/or your house IP address to have a more secure set-up.
sudo firewall-cmd --permanent --zone=trusted --add-port=3389/tcp sudo firewall-cmd --reload
sudo firewall-cmd --zone=trusted --list-all
trusted (active) target: ACCEPT ports: 3389/tcp [...]
sudo yum groupinstall xfce sudo yum install tigervnc-server xrdp
sudo systemctl enable xrdp.service sudo systemctl start xrdp
You can now use your Remote Desktop client from your laptop to connect to your VM’s remote desktop. You may have to create a linux user first in your VM, with a password, such as:
sudo adduser fred # first create a user `fred` (use a name that suits you best) sudo passwd fred # and then set the password for user `fred`
The following steps describe the procedure for setting up Xrdp in CentOS 6. Other distributions may require some variation, but the guidelines should remain analogous.
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3389 -j ACCEPT
reload the firewall configuration, using
service iptables reload
yum install -y tigervnc-server xrdp
chkconfig --levels 5 xrdp on service xrdp start
On newer Fedora-based systems, use
systemctl enable xrdp systemctl start xrdp systemctl enable xrdp-sesman systemctl start xrdp-sesman
You can now log in on the virtual machine using RDP. From Windows or Mac OSX, use the Remote Desktop Connection client, sometimes supplied as an additional package to Microsoft Office. On a Linux desktop, use Rdesktop.
Make sure to set the display to millions of colors (Mac OsX) or high color (16-bits) (Windows), because thousands of colors (Mac OsX) or high color (15-bits) (Windows) will give you a non-descriptive error.
We have a full page on installing Windows, where we explain how serve access to Remote Desktop from it.