How to Set Up Remote Desktop on Ubuntu Server


How to Set Up Remote Desktop on Ubuntu Server

Video Training

Remote desktop access on Ubuntu Server can be extremely useful for managing tasks that benefit from a graphical interface. Using the x11vnc service, you can set up remote access with ease. This guide walks you through each step of the setup process, so you can securely connect to your Ubuntu Server from anywhere.

Prerequisites

To follow this guide, you’ll need:

  • An Ubuntu Server installation
  • Terminal access with sudo privileges

Let’s dive into the step-by-step process of setting up a remote desktop on your Ubuntu Server.

Step 1: Update and Upgrade Your System

First, make sure your server’s packages are up to date.

Run the following command:

sudo apt update && sudo apt upgrade -y

This will update the list of available packages and install the latest versions of those packages.

Step 2: Install XFCE Desktop Environment

Since Ubuntu Server lacks a graphical interface by default, you’ll need to install one. We’re using the lightweight XFCE desktop environment to minimize the load on server resources.

Run:

sudo apt install xfce4 xfce4-goodies -y

The xfce4-goodies package includes additional features and tools that enhance the XFCE desktop experience.

Step 3: Reboot Your Server

To apply these changes, reboot your server using:

sudo reboot

After the reboot, your system will have XFCE installed as the graphical interface.

Step 4: Install x11vnc

The x11vnc package allows you to connect remotely to your server’s desktop environment. Install it by running:

sudo apt install x11vnc -y

Step 5: Create the x11vnc Service File

To make the x11vnc service start automatically when your server boots, create a service file.

Open the service file in a text editor:

sudo nano /lib/systemd/system/x11vnc.service

Copy and paste the following code into the file, and modify the -passwd field with a strong password to secure your connection:

[Unit] 

Description=x11vnc service 

After=display-manager.service network.target syslog.target 

[Service] 

Type=simple 

ExecStart=/usr/bin/x11vnc -forever -display :0 -auth guess -passwd  YourPassword 

ExecStop=/usr/bin/killall x11vnc 

Restart=on-failure 

[Install] 

WantedBy=multi-user.target

Step 6: Enable and Start the x11vnc Service

Once you’ve created the service file, enable and start the x11vnc service to allow remote connections:

Run the following commands to reload systemd, enable the service to start on boot, and start it immediately:

sudo systemctl daemon-reload
sudo systemctl enable x11vnc.service sudo systemctl start x11vnc.service

You can verify that the service is running correctly by checking its status:

sudo systemctl status x11vnc.service

If the service is running, you should see an output indicating that x11vnc is active.

Step 7: Connect to the Ubuntu Server from Your Local Machine

With x11vnc running, you can now connect remotely. Open a VNC viewer application on your local machine (such as RealVNC or TigerVNC) and enter your server’s IP address along with the password you set in the service file.

Conclusion

By following these steps, you’ve set up remote desktop access to your Ubuntu Server, allowing you to manage it through a graphical interface securely. This setup is lightweight and ensures you can access the server without needing to log in directly.

For any issues, check the x11vnc logs and adjust firewall settings if needed to ensure the connection goes through. With remote desktop configured, managing your server is simpler and more efficient! 

Leave a Reply

Your email address will not be published. Required fields are marked *