Just some quick notes on how to deploy Ubuntu 18.04 LTS in a Google Cloud VM
In past articles such:
- MQTT broker with secure (TLS) communication on Ubuntu 18.04 LTS and an ESP32 MQTT-client
- Using Certbot and Express.js to secure your CRA with React Hooks on Ubuntu 18
we have deployed our work on a public server. In this article, we look at how to set up a minimal installation on Google Cloud to run our applications.
Background
You can easily create a virtual machine (VM) hosted on Google’s infrastructure. You just need to create a Google Cloud Platform project, enable billing and then go to the VM instance page.
Ubuntu 18.04 LTS Minimal setup
Below you see my minimal setup.
Setup of password
First, you need to set a password, easily done via:
sudo passwd
Firewall Settings
Now it is time to set up a firewall.
sudo apt-get install ufw
sudo ufw allow OpenSSH
sudo ufw enable
Check that everything is up and running:
sudo ufw status
Fail2Ban
Fail2Ban is an intrusion prevention software framework that protects computer servers from brute-force attacks.
sudo apt install fail2ban
sudo service fail2ban start
Time to restart the machine.
build-essential
The VM instance is going to be used both for deployment and development; not something that is typically recommended but for now it is fine. In order to do some develompent, we need to install C, C++ Compiler and Development (build-essential) Tools in Debian/Ubuntu.
sudo apt-get update && sudo apt-get install build-essential
Copy keys to the server
From now on we want to login using certificates instead of username/password.
vi /etc/ssh/sshd_config#LoginGraceTime 2m
#PermitRootLogin prohibit-password
#StrictModes yes
#MaxAuthTries 6
#MaxSessions 10PubkeyAuthentication yes# Expect .ssh/authorized_keys2 to be disregarded by default in future.
#AuthorizedKeysFile .ssh/authorized_keys .ssh/authorized_keys2ssh-copy-id -i ~/.ssh/mykey user@host
Add a new sudo user
Add new user with sudo privileges to do the work.
sudo adduser <username>
Add the new user to the sudo group.
sudo usermod -aG sudo <username>
Applications
Some applications of our applications.
sudo apt-get install vim
sudo apt-get install mosquitto
sudo apt-get install mosquitto-clients
sudo apt-get install mc
sudo apt-get install git
Installing Node.js
Installing Node.Js using the node version manager nvm.
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bashnvm install 10.16.0node -vv10.16.0
For sudo to be able to use Node.js
sudo ln -s /home/sudi/.nvm/versions/node/v10.16.0/bin/node /usr/bin/node
sudo ln -s /home/sudi/.nvm/versions/node/v10.16.0/lib/node /usr/lib/node
sudo ln -s /home/sudi/.nvm/versions/node/v10.16.0/bin/npm /usr/bin/npm
sudo ln -s /home/sudi/.nvm/versions/node/v10.16.0/bin/node-waf /usr/bin/node-waf
Thank you for reading! Take care and hope to see you soon. 🙏🏽
This article is a living document please reach out to me if you want to contribute or see anything inaccurate here. This article is part of our “Boosting Innovation” project.