Basic configuration guide for Oracle Cloud virtual machine after setup

Setting up a virtual machine running Ubuntu on Oracle Cloud can seem daunting, but with the right steps, it can be a straightforward process. Whether you are a seasoned administrator or just starting out, having a virtual machine running on the cloud can provide you with greater flexibility and scalability. In this guide, we will walk through the steps of configuring a basic virtual machine running Ubuntu on the Oracle Cloud. We will cover the necessary prerequisites, the creation of the virtual machine, and the configuration of the network and security settings. By the end of this guide, you will have a basic virtual machine up and running on the Oracle Cloud, ready for you to use for your business or personal needs.

Table of contents

I. Network configuration for virtual machines

The first thing you need to do after setting up a virtual machine on Oracle Cloud is to configure the network for it. By default, Oracle will block all connections to the virtual machine, except port 22 for SSH connections. We need to reconfigure to be able to use the virtual machine for later installed applications: Web server, DNS server, etc.

From the virtual machine management page, click on Subnet: subnet-2021…
Click on the Default Security List for…
Click Add Ingress Rules

Enter content:

  • Source Type: keep CIDR
  • Souce CIDR: 0.0.0.0/0
  • IP Protocol: choose TCP/UDP or whatever protocol you need. If unsure, choose All Protocol
  • Source Port Range: leave it blank
  • Destination Port Range: enter the port you need to open, for example: 80, 443, 51820
  • Description: comment, write anything.
Create Rule to open port 80. Click Add Ingress Rules

It is done. The virtual machine has been connected to port 80 – TCP.

You do the same when you need to open connections for other ports.

II. Allow SSH connection with password

The first thing I usually do after creating a new virtual machine is to edit the Open-SSH Server configuration to allow SSH connections with a password. No need to use SSH keys anymore.

Logging in with a password won’t be secure using an SSH Key, but it’s much more convenient if you use multiple computers to connect to the virtual machine. Save time copying Private Key back and forth between machines. Just pay attention to create a password that is long and complex enough to be safe to be hacked.

To allow SSH connection to the virtual machine with a password, it is necessary to edit the parameters in the file sshd_config

sudo nano /etc/ssh/sshd_config

Find the line PasswordAuthentication and changed to yes. You can use the keyboard shortcut Ctrl+W to find it quickly.

# To disable tunneled clear text passwords, change to no here!
PasswordAuthentication yes

Save with the command Ctrl + O, select Yes and press Ctrl + X to exit. Now restart the ssh service with the command

sudo service ssh restart

III. Create a sudo account

Next, I will create an additional sudo account on the virtual machine used to log in and manage.

Create a new account with your individual username. Remember to replace it with any other username you like.

sudo adduser [your user]

The system will ask to create a password and provide personal information for the new account. Remember to create a complex password (don’t use 123456 or abcdef). The information section Full Name, Room Number, etc. can be left blank and Enter several times, then select Y to confirm and done.

Add this new account to the sudo group. Group sudo is a group with administrative rights on Linux.

sudo usermod -aG sudo thuanbui

To check the new account’s sudo privileges, first switch to this new account

su - thuanbui

Next, try typing the following command

sudo ls -la /root

Enter the password of the account you created earlier

[sudo] password for thuanbui:

The results received as follows mean that the new account has sudo rights, can install and configure the virtual machine comfortably.

[email protected]:~$ sudo ls -la /root
total 28
drwx------  5 root root 4096 Aug 22 09:59 .
drwxr-xr-x 19 root root 4096 Aug 22 08:23 ..
-rw-r--r--  1 root root 3106 Dec  5  2019 .bashrc
drwxr-xr-x  3 root root 4096 Aug 22 09:59 .local
-rw-r--r--  1 root root  161 Dec  5  2019 .profile
drwx------  2 root root 4096 Aug 22 08:23 .ssh
drwxr-xr-x  4 root root 4096 Aug 22 08:23 snap

You can now turn off Putty and log back into the virtual machine with the account and password you just set up.

IV. Firewall configuration

In addition to configuring the subnet on the admin page of Oracle Cloud. You also have to configure the network configuration on Ubuntu to connect to the services on the virtual machine.

By default, the Ubuntu operating system on Oracle will block all ports. You need to configure the firewall using iptables to access virtual machines over the Internet.

For example, if you want to access the webserver (port 80 TCP) to the virtual machine, you need to type the following command

sudo iptables -I INPUT 6 -m state --state NEW -p tcp --dport 80 -j ACCEPT
sudo netfilter-persistent save

Replace port 80 and the tcp protocol with any other port or protocol you need to use.

A simpler way is to install UFW to manage the firewall. I have shared instructions in the article below.

UFW Tutorial: Configure and Manage Firewalls on Linux

It is done. You already have a free virtual machine to study and get acquainted with Linux / Web Server /…

You can also install AdGuard Home on this virtual machine to use as an ad-blocking DNS Server for your home network.

Instructions to install Adguard Home – block ads for the whole family

Or set up a VPN Server on a virtual machine using WireHole-UI for more secure network access.

Instructions for setting up a free VPN Server with Oracle Cloud VPS

If you need any help, you can ask questions below. Good luck with the installation and configuration.

If my article has provided valuable insights and information to you, consider showing your appreciation with a virtual pat on the back or a kind message. Your encouragement will drive me to continue creating and sharing informative content. Thank you for taking the time to read!

Leave a Reply

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