How to setup Ubuntu 20.04 Server for the first time

In this guide we are going to learn how to set up your Ubuntu server after fresh install.

Logging as root into the server

After fresh installation, the server usually comes with a root account which can be used to log in to your server. Root account has all the privileges which if you are not careful with it you can do more harm to your system. So you are discouraged from using it. So the first thing you can do is to create a regular user and give sudo permissions so that they may run administrative commands with limitations.

To start off, you will need to log in to your server. Ensure you know your server public IP address. Use the following command to log in as root to your server.

$ ssh root@<public_IP_Address>

Public IP Address is your server’s IP address. Accept the warnings that comes with authenticity and input your root password. Alternatively, if you are using SSH key to authenticate, provide your passphrase.

Creating new Server User

Once logged in as root the next thing is to create a user with sudo privileges. Let us create our new user with the following command. Open terminal as root

$ adduser nextgentips
Adding new User

Granting Administrative privileges

The user created above have regular privileges, for it to perform administrative tasks, sudo privileges must be assigned. The new user must prefix sudo in every command typed to gain all administrative roles.

To add new user to these privileges, you must add the new user to sudo group.

As root user run the following command to add sudo group to the user.

$ usermod -aG sudo nextgentips

-a stands for append

G argument tells the usermod to change a users group settings.

Set up Basic Firewall

A firewall is a network security system that monitors and controls incoming and outgoing network traffic based on predetermined security rules. A firewall typically establishes a barrier between a trusted network and an untrusted network, such as the Internet.

Ubuntu servers comes with what we call Uncomplicated firewall (UFW). We use UFW firewall to make sure only connections to certain services are only allowed. Applications register their profiles with UFW upon installation.

$ ufw app list

# shows the current available profiles 

Allow SSH connections so that you can be able to login the next time. Use the following command to do that.

$ ufw allow openSSH

Then you can enable the firewall with the following command:

$ ufw enable

Let’s check the status now with the following command.

$ ufw status 

You are now a regular user you can SSH into your system with your credentials now by using the following command:

$ ssh nextgentips@<your_ip_address>

That is all for now. You are now good to use your new user.

About Kipkoech Sang

I am a technology enthusiast who loves to share gained knowledge through offering daily tips as a way of empowering others. I am fan of Linux and all other things open source.
View all posts by Kipkoech Sang →

Leave a Reply

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