If you’re aUbuntu user, you can connect to a remote desktop session on your computer by using the following steps:
- Open the Terminal window and type “ssh” into the text field.
- Type “xterm” into the text field and press Enter.
- Type “ubuntu@localhost:~$ ssh” and press Enter.
- You will be connected to your Ubuntu computer’s localhost address and able to use its tools, such as windows explorer, firefox, and so on.
Ubuntu’s Built-In “Screen Sharing” Is a VNC Server
When you make an SSH connection to a remote Ubuntu Linux computer, you get a terminal window interface. That’s perfectly fine for many tasks, such as system administration, and it has the advantage of being a lightweight connection. There are no graphics to transmit from the host computer to the local client, so it’s fast and easy to set up.
If you want to see graphical applications installed on the remote host on your local computer, you can do that with a PuTTY connection, which is also easy to set up.
But what if you want to go all-in and see the entire remote desktop and it as though you were sitting right in front of it? Simple—you use “screen sharing,” also known as desktop sharing.
To do this, you configure screen sharing on the remote computer and connect to it with a VNC client on the local computer. And—you’ve guessed it—it’s easy to set up.
Although this article concentrates on Ubuntu, this is really a GNOME thing. It works equally well on any other Linux that has a GNOME version of their distribution. Manjaro and Fedora, for example, have the same options and settings described below. We went through this process with Ubuntu 18.04 LTS.
How to Enable Screen Sharing on the Remote Host
These are the settings you make on the remote Ubuntu computer you’re going to connect to.
On the system menu, click the Settings icon.
In the “Settings” dialog, click “Sharing” in the side panel, and then click the “Sharing” toggle On.
Click “Off” next to the “Screen Sharing” option, so it changes to “On.”
The “Screen Sharing” dialog appears. Click the toggle in the title bar to turn it On.
When the toggle is turned on, the slider at the bottom of the dialog also changes to On.
By default, “Access Options” is set to “New Connections Must Ask for Access.” This means every user has to confirm each connection. If you’re trying to connect remotely, this won’t work, so configure a password instead. Select the “Require a Password” radio button and type a password in the “Password” field.
This password is not related to any user account, but it must be provided by remote clients when they connect. It’s limited to eight characters, so make it as complex as possible. If you forget the password, you can always repeat these steps to reset it.
After you’ve typed a password, close the “Screen Sharing” and “Settings” dialogs.
Encryption is used to transfer and verify the password when a connection request is made. Whether the rest of the VNC traffic is encrypted depends on the capabilities of the VNC client. This is more of a concern on connections across the internet.
Unless you have a secure VPN between your two sites or the VNC connection is otherwise protected (by being tunneled through SSH, for example), it’s safe to assume the connection is not encrypted. Avoid opening sensitive or private documents over the connection.
Now, we need to configure a client to connect to this computer, and that brings us to IP addresses.
How to Access the Remote System Over the Internet
Warning: We recommend using VNC only over a local network. Ubuntu’s Screen Sharing won’t let you set a password longer than eight characters. If you want to connect remotely, we recommend setting up a virtual private network (VPN) server on the network with the remote Ubuntu system. Connect to the VPN from the internet, and then connect to the VNC system through the VPN. This avoids exposing the VNC server directly to the network. However, if you want to make the Screen Sharing server accessible over the internet anyway, this section shows you how.
If you’re not on the same network as the remote Ubuntu computer, you’re going to need to connect to it over the internet. The IP address a network presents to the internet is its public IP address. It’s actually the IP address of the router, which is assigned by the Internet Service Provider (ISP). So, we need to find that IP address.
The easiest way to do this is type “my ip” into the Google search bar on the remote Ubuntu computer and then press Enter.
This is good to know, but it’s not enough to make a connection to the remote computer.
Imagine you want to call someone at a hotel. You can’t call their room directly. You first call the hotel and give them the name of the guest you want to speak to. The switchboard operator checks the hotel directory and puts your call through to the correct room.
The router on a network acts as the switchboard operator. So, the router on the remote network must be configured to forward VNC connection requests to the Ubuntu PC. This is a networking technique called port forwarding.
But let’s back up a moment. Your ISP might have assigned you either a static public IP address or a dynamic public IP address. A static public IP is permanent, while a dynamic public IP address likely changes when your router reboots. If your public IP address changes periodically, remote computers won’t know to which IP address to send their connection request.
The solution is something called dynamic domain name system (DDNS). There are free DDNS providers you can use. The general process is:
You register with the DDNS provider and receive a static web address. You configure your router to periodically contact your DDNS provider and inform it of its current IP address. The DDNS system updates its record of your web address, so it points to your IP address. This means connection requests made to your web address are always forwarded to your current—and correct—IP address.
RELATED: How To Easily Access Your Home Network From Anywhere With Dynamic DNS
Using our hotel analogy, the connection request thus far has made it to the hotel switchboard. To complete the connection, the router must perform the port forwarding.
Routers can send traffic that arrives on a specific port to a specific computer. Once they’ve been configured to send VNC traffic to a particular computer, all incoming VNC connection requests are directed to that computer.
If you’re going to use VNC across the internet, it’s advisable to use a nonstandard port. By default, the remote Ubuntu computer listens for VNC connection requests on TCP/IP port 5900.
This is a well-defined convention, but we verified it anyway by analyzing some network traffic:
We can mask that detail from the outside world by using a nonstandard port, like 43025. The remote router must then be configured to forward connection requests for port 43025—or whichever port you choose—to the Ubuntu computer on port 5900.
RELATED: How to Forward Ports on Your Router
That’s like ringing the hotel and asking to speak to the geek in room 43025. The operator knows the geek is really in room 5900 and connects your call. The geek doesn’t know what room you asked for and he doesn’t care. You don’t know what room the geek is really in, nor do you care.
The conversation between you can proceed, and that was the desired outcome.
RELATED: How to Set DNS Search Order in Ubuntu 18.04 using NetPlan
How to Connect From a Linux System
The client computer that’s going to connect to our Ubuntu computer doesn’t have to be running Ubuntu. As we’ll see when we configure a Windows client, it doesn’t even have to be running Linux.
To reinforce the distribution-agnostic nature of the connection, we’re going to connect from a computer running Manjaro. The steps are the same for other distributions.
We’re going to make a Virtual Computing Network (VNC) connection, so we need to use a client capable of that. Remmina is a remote desktop client that supports VNC, and it’s bundled with many Linux distributions, including Ubuntu. It’s easy to install (if it’s not already) from the package manager of other distributions.
Press the Super key, located between the left-hand Ctrl and Alt keys, and then type the first few letters of “remmina.” The Remmina icon will appear at the top of the screen.
Click the icon to launch Remmina.
When the Remmina dialog appears, click the “+” sign to create a new connection.
The Remote Desktop Preference dialog appears. This is where you input details about the connection to the remote computer. These can be saved and reused, so you don’t have to retype them each time you want to connect.
Provide a “Name” for this connection. You can choose anything, but it should be something that identifies the computer to which you’ll be connecting.
You can leave the “Group” field blank or provide a name for the group. If you configure many connections, they can be grouped into categories, such as Linux Computers, Windows Computers, Head Office, Local Branches, and so on.
Select “VNC – VNC Viewer” from the “Protocol” drop-down menu. More fields appear now that Remmina knows which protocol we want to use.
In the “Server” field, enter either the IP address or network name of the remote computer. The “User Name” field is not related to a Linux user account; you can type anything here. The “Password” must be the password you used when you set up screen sharing on the remote Ubuntu machine.
Select a value from the “Colour Depth” drop-down menu. Lower values are more responsive, but the screen will look flat and slightly psychedelic. If the visuals aren’t important to you, and you favor speed over prettiness, choose a low value. Higher values look more like the actual desktop. On slow connections, however, they can be sluggish to update, and mouse movements can be erratic.
Select “Medium” from the “Quality” drop-down menu. If everything seems fine when you’re connected, you can adjust this to a higher value for subsequent connections. But to make sure the connection works, “Medium” is a good starting point.
After you configure your connection details, click the “Save” button. You return to the main Remmina window, and your new connection is listed there.
Double-click the connection to connect to the remote Ubuntu computer. The remote computer must be powered on, and the person who set up screen sharing must be logged in. He’ll see a notification that you’re connected and controlling his desktop, which is only polite.
It’s important to note you’re not logging in to the remote computer—you’re taking over the session of the person who is already logged in.
Remmina shows you the remote desktop in a window on your computer. You can move the mouse and use the keyboard the same as if you were sitting at the remote computer.
The icons on the side panel allow you to maximize the window, scale the remote desktop to the Remmina window, go to full-screen view, and so on. Hover your mouse over the icons to get a tool-tip to see what they do.
When you’ve finished with your remote connection, disconnect from the remote computer by clicking the bottom icon in the side panel.
How to Connect From a Windows System
Windows has compatibility problems with the encryption used in the VNC connection, so we’ll make the use of encryption optional. This way, computers that use the encryption can do so, and those that don’t can connect without it.
Warning: Anyone on your network will be able to eavesdrop on the connection. This is another reason why it’s good to use this on a local network or via a VPN—not over the internet!
Use this command on the remote Ubuntu computer to make encryption optional:
If you don’t have RealVNC on your Windows computer, download and install it. The installation is simple—just click the “Next” buttons and accept the defaults.
After it’s installed, launch the “VNC Viewer” application from the Start menu. Select “New Connection” from the “File” menu.
The “Properties” dialog appears. Type the IP address or network name of the remote Ubuntu server in the “VNC Server” field.
In the “Name” field, type a name for this connection, so you recognize which remote computer it connects to. You can provide a label in the “Label” field or leave it blank.
In the “Security” group, leave the “Encryption” drop-down menu set to “Let VNC Server Choose.” Ensure that both the “Authenticate using single sign-on (SSO) if possible” and the “Authenticate using a smartcard or certificate store if possible” options are unchecked.
Click “OK” to save your settings. An icon for your new connection appears in the main window.
Double-click the icon to connect to the remote computer. You’ll see a splash screen as the connection is initiated.
Because you made encryption optional, and it won’t be used from the Windows computer, you see a warning dialog.
Select the “Don’t warn me about this again on this computer” checkbox, and then click “Continue.”
You see the desktop of the remote Ubuntu computer in the RealVNC window.
Remember, the Windows VNC connection is not encrypted, so don’t open private documents or emails using this connection.
Never Too Far Away
If you need to access an Ubuntu computer remotely, you now have an easy way to do so. As a bonus feature, RealVNC also has a free app for Android smartphones and iPhones. You can set it up by following the same steps above.