Ubuntu 20.04 enable remote desktop command line
Not using Ubuntu 20.04? Choose a different version or distro. Debian 10 CentOS 8 xRDP is an open source implementation of the Remote Desktop Protocol (RDP), developed by Microsoft. RDP allows users to establish secure connections to other computers over the internet, and use their mouse and keyboard to interact with the remote servers graphical user interface in the same way they would interact with a regular desktop. Show
xRDP allows connections using RDP to machines running non-Microsoft operating systems, such as Linux or BSD. It accepts connections from a variety of clients, such as FreeRDP, rdesktop, NeutrinoRDP and Microsoft Remote Desktop Client (for Windows, macOS, iOS and Android). You might also be interested in alternative remote desktop technologies for Ubuntu, such as VNC, Chrome Remote Desktop, NX (via a software called X2Go) or Xpra. They aim for similar goals of controlling remote desktops, however, the methods by which they achieve them differ. ObjectivesIn this tutorial youll learn to install xRDP on an Ubuntu 20.04 server, install desktop environments (GUI) on it, connect to the remote machine from multiple operating systems, and adjust some settings to try and speed up slower connections. Table of Contents
Prerequisites
Step 1 Install xRDP on Ubuntu 20.04Start by updating the systems package index: sudo apt updateTo install xRDP run: sudo apt -y install xrdpThe installation may take some time. Once its installed, the service should be running automatically. We can check the status of the xrdp service by running: sudo systemctl status xrdpThe output should look something like this: xrdp.service - xrdp daemon Loaded: loaded (/lib/systemd/system/xrdp.service; enabled; vendor preset: enabled) Active: active (running) since Fri 2021-03-26 14:11:39 UTC; 7h ago Docs: man:xrdp(8) man:xrdp.ini(5) Main PID: 207349 (xrdp) Tasks: 1 (limit: 4714) Memory: 1.2M CGroup: /system.slice/xrdp.service 207349 /usr/sbin/xrdp Mar 26 14:11:38 bytexd xrdp[207328]: (207328)(140179238758208)[INFO ] address [0.0.0.0] port [3389] mode 1 Mar 26 14:11:38 bytexd xrdp[207328]: (207328)(140179238758208)[INFO ] listening to port 3389 on 0.0.0.0 Mar 26 14:11:38 bytexd xrdp[207328]: (207328)(140179238758208)[INFO ] xrdp_listen_pp done Mar 26 14:11:38 bytexd xrdp[207328]: (207328)(140179238758208)[DEBUG] Closed socket 7 (AF_INET6 :: port 3389) Mar 26 14:11:38 bytexd systemd[1]: xrdp.service: Can't open PID file /run/xrdp/xrdp.pid (yet?) after start: Operation not permitted Mar 26 14:11:39 bytexd systemd[1]: Started xrdp daemon. Mar 26 14:11:40 bytexd xrdp[207349]: (207349)(140179238758208)[INFO ] starting xrdp with pid 207349 Mar 26 14:11:40 bytexd xrdp[207349]: (207349)(140179238758208)[INFO ] address [0.0.0.0] port [3389] mode 1 Mar 26 14:11:40 bytexd xrdp[207349]: (207349)(140179238758208)[INFO ] listening to port 3389 on 0.0.0.0 Mar 26 14:11:40 bytexd xrdp[207349]: (207349)(140179238758208)[INFO ] xrdp_listen_pp doneRegarding xrdp.service: Cant open PID file /run/xrdp/xrdp.pid (yet?) after start: Operation not permitted: I am not 100% certain of this, but I currently believe that this warning is harmless and is just a test to know if another instance isnt already running. [source] Finally, xRDP needs to use the /etc/ssl/private/ssl-cert-snakeoil.key file, and to do so it needs to be added to the ssl-cert group. /etc/ssl/private/ssl-cert-snakeoil.key is used in cases when no other SSL certificate is installed or configured, but encrypted communication is still enabled and desired. It still encrypts traffic, however since it lacks a root authority signature, it is still vulnerable to most man-in-the-middle attacks. That is why its called snakeoil. sudo adduser xrdp ssl-certOutput: Adding user 'xrdp' to group 'ssl-cert' ... Adding user xrdp to group ssl-cert Done.Restart xRDP to apply changes: sudo systemctl restart xrdpNow xRDP should be successfully installed on your system. Configure FirewallIf your firewall is active, then you need to allow port 3389, which is the default port used by RDP. If youre running UFW (Uncomplicated Firewall), to allow port 3389 you can do something like the following, replacing 1.2.3.4 with the IP for which you want to allow port 3389.
Configuring xRDPBy default xRDP doesnt require custom configuration, however you can customize it, if you need to, by editing the following file: sudo nano /etc/xrdp/xrdp.iniFor a comprehensive tutorial on configuring xrdp.ini you can check xrdp.ini: Configuration file for xrdp(8) Linux Man Pages (5) Important Note Please remember to restart the xrdp service after any edit to xrdp.ini, for the changes to take effect. Step 2 Install Your Preferred Desktop Environment on Ubuntu 20.04In Linux, a Desktop Environment is an interface to the operating system. It is a layer of software that sits on top of the operating system and allows users to interact with the computer. The name Desktop Environment comes from the fact that it is meant to be a desktop, or more specifically, a graphical user interface (GUI). The graphical user interface includes the desktop environments theme, window manager, icon theme, and so on. In addition, most desktop environments include a window manager, which controls the appearance of windows, and a set of other software, such as a text editor, terminal emulator, and file manager. There are many great desktop environments available for Ubuntu 20.04 and you can very easily change your desktop environment to suit your needs. Installing Popular Desktop EnvironmentsIn this tutorial well just install XFCE, however you can follow this article to install 8 of the most popular desktop environments How to Install a Desktop Environment (GUI) on an Ubuntu 20.04 Server. Installing XFCE Desktop EnvironmentXFCE is lightweight and one of the most popular desktop environments. It is a minimal desktop environment with a focus on speed and low system resource usage, while still being visually appealing. It uses Xfwm for its window manager, and includes a settings manager for many of XFCEs components. It is the default desktop environment for Xubuntu, a distro based on Ubuntu (also referred to as a flavor of Ubuntu). You can read more about it on the official website at xfce.org To install the XFCE desktop environment, run: sudo apt install xfce4This is what XFCE looks like on Ubuntu 20.04 when connected via xRDP: With xRDP installed on your machine, along with a desktop environment, we should be ready to connect to the remote machine. Switching Between Desktop EnvironmentsYou can install multiple desktop environments at the same time and choose which one you want to use when you log in. To switch between them you can follow our short tutorial How to Switch Desktop Environments in Ubuntu/Debian From the Command Line Step 3 Connect to Your Ubuntu 20.04 Remote Desktop using xRDPTo connect to the remote Ubuntu machine using xRDP we can use multiple operating systems, and we just need an RDP client installed. Windows already comes with it installed, and installing an RDP client on other operating systems is very easy. No matter what OS or RDP client youre using, the process is fairly similar. If youre familiar with how RDP works with connecting to a Windows remote desktop, you know that you run the RDP client, fill in the servers IP or fully qualified domain name (FQDN), along with the user/password and after clicking to connect, youd be connected to the server and controlling it. With Linux machines it differs just slightly. We launch the client, and we can fill in just the remote machines IP address or its fully qualified domain name, and click to connect. After which were presented with a login screen in which we input our username and password, then click OK. You can also fill in the details beforehand and youll automatically be logged in, however you may not always be prompted to do so. It can depend on the RDP client that youre using. Connecting from WindowsWindows should come with an RDP client already installed. The app is called Remote Desktop Connection. To access it, in the search box in the Windows taskbar, type Remote Desktop Connection and you should see the Remote Desktop Connection App. Upon clicking it, if this is the first time accessing it, you should see something like this: To connect to your Ubuntu 20.04 remote desktop, enter the remote machines IP or fully qualified domain name, and click connect. If this is the first time youre connecting, you may see a warning such as The identity of the remote computer cannot be verified. Do you want to connect anyway? We trust this computer, so you can click Yes. The reason youre seeing this is because the server is unable to verify with a trusted authority that the machine you are trying to connect to matches the name you are trying to connect to. Thus it is vulnerable to man-in-the-middle attacks. We just set up this machine, however, and are assuming that its safe, so you can click Yes and continue with the connection. You should then see the login screen where you can input your username/password and click OK, and youll be connected to your remote desktop. Connecting from LinuxThere are multiple good RDP clients for Linux. My favorite is Remmina because it is very user friendly, very popular, and you can use it for SSH and VNC, as well. Its sort of a one stop shop for connecting to other machines. To install it on your distro follow the instructions from Remminas installation page https://remmina.org/how-to-install-remmina/ When you run it youll see the Remmina interface. Click on the + Icon in the upper left corner to start creating a new connection profile. A window will pop-up, Remote Desktop Preference, where you can configure the connection profile. Well cover the minimum required to connect to your Ubuntu 20.04 remote desktop. Name: Fill the name you want for the connection. It is just a reference and its for your convenience, and does not affect the connection in any way. You can now click Connect to directly connect to the remote desktop or Save and Connect to save the configuration for future use, and also immediately connect to the remote desktop. Connecting from OSXTo connect from OSX first install the Microsoft Remote Desktop App form the App Store. Once youve installed and launched it you should find a button to Add PC. Click it and then you should see a form where we can enter our Ubuntu 20.04 remote desktops connection details. Fill it as follows: PC Name: The IP or fully qualified domain name of the remote machine Add the configuration and you should be able to connect to the Ubuntu 20.04 machine, after which youll be presented with the login screen where you can input your username and password. Connecting from Android/iOSBoth the remote desktop clients for Android and iOS should be similar, as theyre both developed by Microsoft. Android: The app is currently named Remote Desktop 8 by Microsoft Corporation in Google Play (at the time of writing, March 2021) After installing and launching it you can add and save a configuration for connecting to the remote desktop in the future. Well fill in the minimum required to connect. Tap Add desktop and fill in the following: PC Name: the IP or fully qualified domain name of the remote desktop Tap SAVE and the configuration should be saved. If you tap on it then the connection process should begin. You will end up on the login screen and youll move the cursor by dragging it. Optimize xRDP Laggy/Slow ConnectionsThere may be cases when your connection is slow due to your internet connection. In this case, a solution for this is to reduce the experience/visual styles of the remote connection, and to prioritize the remote desktop connection over other running processes on our machine. These are not guaranteed to fix speed, but theyre worth trying. Using a More Lightweight Desktop EnvironmentIn case youre using heavier desktop environments, such as KDE, you might try switching to more lightweight ones like LXQt or XFCE. If its still slow, you might even try switching to just using OpenBox, which isnt really a desktop environment, but you can still have a functional remote desktop. You have a blank screen and right click for the context menu and you can select the apps to open from there. Its a little less aesthetic, but it works and its lightweight. Improving Connection from WindowsThere are 2 things we can do to try and improve RDP connection on Windows:
Improving Connection from Linux (Remmina)Important Note I have not properly tested these methods, so I cannot guarantee they will make a big impact on your remote desktop connection. In Remmina you can try improving the remote desktop connection by:
ConclusionxRDP allows you to connect to a remote desktop and control it through its graphical user interface. Hopefully this article helped you set up xRDP on your Ubuntu 20.04 server, install your preferred desktop environment, connect to it from your OS, and improve connection speed. If you have encountered any issues or have any further questions, feel free to leave us a comment or contact us. |