Google Cloud Platform

Create your own Ubuntu Server on Google Cloud Platform

Google Cloud Platform offers a number of services ranging from App Engine, fully managed Kubernetes, Database as a Service, Function as a Service, Object store and much more. It is easy enough to get overwhelmed by all the functionalities, each as attractive as other. The Google Cloud Platform dashboard, in my opinion, doesn’t make it any easier for the user, either!

Sometimes, all we need is a simple VM. Despite the uprising of containers, VMs are still useful and simple. You don’t have to worry about giving your application permissions for a different Database service, an object store service etc. Everything from compute to storage can be contained within a single (scalable) VM.

In this post, let’s dive into how one can spin up a Ubuntu server in Google’s Cloud Platform.

Google Compute Engine (GCE)

GCE is the product that actually lets you configure and deploy virtual machines on Google’s infrastructure. Everything from the amount of resources to the networking capabilities, SSH-keys and Operating system are selected herein.

Login to your Google Cloud Platform dashboard, and search for GCE. At once Compute Engine will show up in the results, click on it.

Here’s an overview of Compute Engine:

As you can see, the side menu has a lot of options for managing your VMs and monitoring them. We will stick to VM instances for now. Since this lets us create a single VM. If you wish to create a group of them “Instance groups” might serve you better.

Let’s start by clicking on Create, as shown in the screenshot above.

A VM template with all the default values provided by Compute Engine will appear. Let’s configure a few of the defauls. I’ll leave the CPU to 1 vCPU and memory to 3.75 GB as those values are good enough for a demo. If you want more/less resources for optimal price and performance, feel free to tweak these parameters.

First thing I will tweak is the boot disk. We want Ubuntu, so, under boot disk, click on Change and select Ubuntu 18.04 LTS. This disk will have the OS installed and the remaining space is what you will use for your application, packages, etc. (unless you are adding extra block storage). So if you want more storage than the default 10GB, make sure to increase the size, as shown below.

Moreover, for better performance you can select SSD persistent disk. This is a significant improvement over standard persistent disk. Once the boot disk is selected to be Ubuntu, we can just create the VM and have a Ubuntu server installed in the cloud for us.

However, let’s configure, for convenience sake, Firewall and SSH keys.

If you wish to host an HTTP or HTTPS server, make sure to check the boxes saying “Allow HTTP Traffic” and “Allow HTTPS Traffic”. Most websites would need this, and so would most API servers, reverse proxy servers, etc. As for the Identity and API access parameters are concerned, you can leave that to default.

Now click on “Management, security, disks…” section to access more customization features. Within this dropdown go to Security and you can paste your public ssh key in here. The username within the key will also be created inside the VM. For example, the key


Will create a user named ranvir with sudo access and place the SSH key within this user’s home directory (~/.ssh/authorized_keys) so you can access the VM remotely.

We are almost done. Review the monthly estimated price this VM will cost you as well as the region where it will be spun up, by scrolling all the way up again. Regions are a subjective, but important parameter. For someone trying to create a VPN, a VPN several time zones away is better suited. On the other hand, if you require lower latencies, you need to select a region nearest to you.

Then click on create and you have your Ubuntu VM up and running!

Post Configuration

In order to make sure that you can ssh into the VM reliably as well as point domain names to this VM, you would need a static public IP address. If you view the Compute Engine dashboard, you will see the status of your VM along with its external (public) IP.

But if you click on the VM’s name (instance-1 in my case) then you will notice that the IP is, in fact, ephemeral.

This means trouble, especially if you are using external domain name servers to point your FQDN towards this IP address. To change this to static, click on Edit, from the top menu. Scroll back to network interfaces (nic0, in our case) and edit it.

Click on Ephemeral under the External IP and select Create IP address.

It will open up a dialogue box asking you for a name to give to this new static IP.  Give it a reasonable name and click Reserve. You will notice that the external IP of the VM has indeed changed and, hopefully, for the last time.

You can now try to ssh into this VM via its external IP. Remember the username that was associated with your public SSH key? Just use that along with the static IP you obtain, like in my case it would be:

$ ssh ranvir@

Your username and IP would be very different from mine, use those instead.

Next steps

When it comes to computation, automation is the name of the game. VMs are often created as a disposable entity in the cloud, especially if you just want to use them for a few hours of testing, or running batch processes, etc.

Now that you know how to create a VM using the GUI, try automating the process using the gcloud CLI or the REST API. Whatever actions you perform on the Compute Engine GUI, an equivalent HTTP request or gcloud command is available in the bottom of the page.

Use them to automate the tedious process of spinning up VMs. This will help you save an enormous amount of time.

About the author

Ranvir Singh

Ranvir Singh

I am a tech and science writer with quite a diverse range of interests. A strong believer of the Unix philosophy. Few of the things I am passionate about include system administration, computer hardware and physics.