Accessing your remote desktop on Google Cloud Platform via NoMachine
By combining NoMachine software with Google Cloud Platform (GCP) infrastructure, you can jumpstart your own remote access and desktop delivery solution for employees, partners and customers alike. Or if it's just for your own use, by installing NoMachine you can get remote access to your own personal desktop hosted in GCP and get the same benefits as you would as if the physical hardware was really yours.
Google Cloud Platform is the Google's cloud-computing service. It provides resizable compute capacity in the cloud, suitable for any organization or individual which needs flexible cloud hosting services. Virtual hosts can be fired up on many OS’s and configurations according to specific needs. This particular tutorial will concentrate on the Linux desktop.
Setting up a Linux desktop hosted on GCP
GCP Linux instances do not come with a GUI, so by default, you need terminal access for all application configuration to get started. Most of the developers/sysadmins working with Linux prefer the command line over Graphical User Interface. But users who are new to Linux will feel more comfortable with a GUI for installing and managing their applications. We will show you how to configure a graphical user interface (GUI) for a GCP Linux instance and then access that GUI using NoMachine.
We're going to install NoMachine (free version) on a virtual Linux host, and then access the desktop of this virtualized Linux OS. You can of course install any of the enterprise-oriented products as well. For this tutorial, we'll install it on Ubuntu 14.04 LTS. NoMachine can be installed on literally any of the Linux flavors, though some of the steps might change depending on what you choose to use. To get started you're going to need SSH to let you remotely log in and administer the Linux VM. Once NoMachine is installed, you'll be able to access the remote desktop securely via NX.
Choosing a Google Cloud VM Instance
Remember you can also refer to their Getting Started Guide: https://cloud.google.com/gcp/getting-started.
Once logged-in, click on “Console”. You will see the Google Cloud Platform dashboard. Click on “Google Cloud Platform” on the top left side, choose “Compute Engine” and click on “VM instances” (Fig. 2).
Fig. 2 - Click on “VM instances”
Choose a Virtual Machine (VM). You can use 'Marketplace' to find the VM instance with the OS of your needs. For this tutorial we've chosen Ubuntu 14.04 (Fig. 3).
Fig. 3 - Once you've chosen the VM type, click on “Create instance” to proceed to create the new VM
Configuring the virtual machine
In the first step, you need to configure the base details and features for your VM: name, region, machine type. There are plenty of possible configurations and you will be asked about creating machine’s type/size, name, username, login method and others.
Important! To enable access to your instance, be sure to choose 'Allow default access' in the 'Access scopes' configuration (Fig. 3).
The default way of accessing the VM instance is using SSH keys. You will find detailed explanation here: https://cloud.google.com/compute/docs/instances/connecting-to-instance.
In this tutorial, we use project-wide SSH keys that provide access and work with all the machines in the same project (because we are constantly deploying many VM’s and it’s simply much more comfortable to do it this way). Alternatively, you can use your own SSH key. In order to do that you need to choose 'Block project-wide SSH key' and paste your public key into the appropriate text area 'Enter entire key data' (Fig. 4).
Fig. 4 - Copy your SSH public key into the 'Enter entire key data' field if you want to use your own SSH key for this VM instance only
Preparing the virtual machine
Once completed the configuration, click on “Create” and wait a few minutes until your virtual machine is deployed. Your VM is almost ready! The new VM will be displayed in the list of VM instances in the GCP dashboard (Fig. 5).
Fig. 5 - Your VM is almost ready
Copy the machine’s public IP address, shown on the right side of instance’s details (“External IP”, Fig. 5), you will need it later. In this example, the IP is: 220.127.116.11
Click on the menu button for your VM instance and go to the “View network details” of the new VM to configure firewall settings and enable incoming connections on tcp port 4000 which is the default NoMachine port for connections by NX protocol.
Now log-in by SSH to your VM instance. Click “SSH” in the row of the VM (Fig. 5). You will be authenticated to the VM by using the SSH keys pair previously set (Fig. 6).
Fig. 6 - Connecting to the VM by SSH and key-based authentication
You are now connected to your VM instance. Next steps will be updating the system, creating the new user nomachine, editing the SSHD configuration to enable password-based authentication and install a desktop environment on the VM since by default it is in a headless mode (Fig. 7).
Fig. 7 - Connected to the Virtual Machine
When you are connected to the remote Virtual Machine via SSH, update the Operating System:
sudo apt-get update
sudo apt-get upgrade -y
Create the nomachine user (also set a password):
sudo adduser nomachine
Install a desktop environment to provide a graphical interface on it:
sudo apt-get install ubuntu-desktop
Configure the system SSHD on the VM to enable password-based authentication.
Edit /etc/ssh/sshd_config by changing “PasswordAuthentication” line from “No” to “Yes”.
Go back to the GCP Dashboard, stop and start your VM.
Wait until it reboots (Fig. 8).
Fig. 8 - Stop and then start the Virtual Machine
Download and save the NoMachine package suitable for the Operating System of your Virtual Machine on your local computer. Then send it to your GCP VM instance via SCP. In our case, the external IP of the VM instance is 35.224.148 (Fig. 9).
Fig. 9 - SCP the NoMachine package to the Virtual Machine
Connect to the Virtual Machine by SSH as you did before and install the NoMachine package:
Close the terminal and go back to GCP Dashboard. Now you're ready to use your NoMachine desktop on GCP Ubuntu 14.04. On your local machine open the NoMachine User Interface and click New. Ceate a new connection by specifying the NX protocol and the proper IP address of the remote host on GCP (Figs. 10 - 11).
Fig. 10 - Select NX as protocol
Fig. 11 - Provide the IP of the VM hosted on GCP
Follow the next step of the wizard, specify login method (in our example it's NX protocol and password-base authentication), give a name to this connection. Once completed, provide credentials to login to the VM on GCP when requested. Here we log-in to as the 'nomachine' user (Fig. 12).
Fig. 12 - Provide username and password to log-in to the GCP's VM
Your NoMachine session is started: pass through the Welcome panels for quick hints on NoMachine features and configuration.
Fig. 13 - Read the NoMachine Welcome panels for hints
You're now connected to the desktop of your Virtual Machine on GCP. Choose the user and enter the username. It’s all done, enjoy your new desktop!
Fig. 14 - You're in!