Create a Virtual Desktop with Debian and NoMachine

Updated on April 8, 2022
Create a Virtual Desktop with Debian and NoMachine header image

Introduction

A Virtual Desktop hosted in the cloud is useful for many applications. This guide explains how to create a virtual desktop on a Debian server with NoMachine, a remote desktop application.

Prerequisites

Before you begin this guide:

1. Install Gnome

  1. Connect to the server as your sudo user with SSH.

  2. Install the required Gnome fonts.

     $ sudo apt install xfonts-100dpi xfonts-100dpi-transcoded xfonts-75dpi xfonts-75dpi-transcoded xfonts-base
  3. Install Gnome.

     $ sudo apt install gnome
  4. Start the Gnome desktop manager.

     $ sudo systemctl start gdm
  5. Verify that Gnome is running by checking the service status.

     $ sudo systemctl status gdm
  6. Switch the server from a terminal-based environment to the desktop environment.

     $ sudo systemctl set-default graphical.target

    You should see output like this:

     Created symlink /etc/systemd/system/default.target → /lib/systemd/system/graphical.target.
  7. Reboot the server for the changes to take effect.

     $ sudo reboot now

When the server reboots, it will end your SSH connection.

2. Install NoMachine

  1. Open a web browser and download the NoMachine for Linux deb amd64 package from the official website. Make note of the download location on your local machine.

  2. Copy the package to the server. Assuming you downloaded it to ~/Downloads on your local machine, you can copy it the server /tmp directory with scp.

     $ scp ~/Downloads/nomachine_<version>_amd64.deb username@<server-ip-address>:~/tmp/

    You can also use SFTP, or a graphical program like Filezilla or Cyberduck to copy the package to the server. If you use those methods, make note of where you upload the file.

  3. Connect to the server as your sudo user with SSH.

  4. Change to the /tmp directory, or where you uploaded the package.

     $ cd /tmp
  5. Install NoMachine.

     $ sudo dpkg -i nomachine_<version>_amd64.deb

    Output:

     NX> 700 Installing: nxserver version: 7.9.2.
     NX> 700 Using installation profile: Debian.
     NX> 700 Install log is: /usr/NX/var/log/nxinstall.log.
     NX> 700 Creating configuration in: /usr/NX/etc/server.cfg.
     NX> 700 Install completed at: Wed Mar 30 20:38:15 2022.
     NX> 700 NoMachine was configured to run the following services:
     NX> 700 NX service on port: 4000

NoMachine is now installed on your server and ready to receive connections.

3. Configure the Firewall

Changing the port number in the next four steps is optional.

The default port for NoMachine is 4000, but you can change the port if needed. Choose a port greater than 1024. For example, to change the port to 7000:

  1. Edit the main configuration file using a text editor of your choice.

     $ sudo nano /usr/NX/etc/server.cfg
  2. Locate the following configuration line:

     #NXPort 4000
  3. Uncomment it and change it to:

     NXPort 7000
  4. Save changes and close the file.

Allow the NoMachine port through the firewall.

  • If you did not change the port:

      $ sudo ufw allow 4000
  • If you changed the port to 7000, for example:

      $ sudo ufw allow 7000

Restart nxserver to apply changes.

$ sudo systemctl restart nxserver

Restart the firewall.

$ sudo ufw reload

Connect to the Debian Virtual Desktop

Setup a NoMachine Connection

  1. On your local computer, download and install the NoMachine package for your operating system.
  2. Start the NoMachine application on your computer.
  3. From the main application window, click +Add.
  4. Assign your connection a name for identification, such as Vultr Desktop Debian Server
  5. Enter the NoMachine server port. The default is 4000, unless you changed in when setting up the firewall in the previous section. If you changed the port, enter the new port number.
  6. Choose NX as the connection protocol
  7. Click Connect to establish a connection to your server.
  8. Click Yes to accept the server certificate fingerprint.
  9. Enter your username and password for the server.
  10. Click Login to start using the remote Debian virtual desktop.
  11. To test your virtual desktop, launch the pre-installed Firefox web browser and start surfing the Internet.

The first NoMachine connection may take a few minutes to set up the Gnome desktop applications.

Next Steps

For more information, refer to the NoMachine documentation.