• Calculating...
  • 4 years ago
  • 3.8K Views

How to create a new user & configure a firewall on Ubuntu 18.4

This tutorial will guide you to set up a new user and to configure the firewall with UFW on Ubuntu 18.04. First, log into your Ubuntu as root user and then go to your SSH or Ubuntu terminal.

 

Adding a new user

Add the user by using adduser command as shown below. Use any preferred name you like after adduser command and you will be asked to create and verify a password for the user.

adduser bishrulhaq

 

Next you’ll be asked to fill in some information about the new user.

Changing the user information for bishrulhaq
Enter the new value, or press ENTER for the default
    Full Name []: bishrulhaq
    Room Number []:
    Work Phone []:
    Home Phone []:
    Other []:
Is the information correct? [Y/n]
 

Next use the usermod command to add the user to the sudo group. On Ubuntu, all members of the sudo group have full sudo privileges.

usermod -aG sudo bishrulhaq

 

Enabling SSH access for newly added User

If you’re using SSH to access the server and password authentication is enabled then you need to copy your local public key to the new user’s ~/.ssh/authorized_keys file to log in successfully.

 

To copy the files with the correct permissions is by using the rsync command. This helps to copy the root user’s .ssh directory and to copy the permissions, modify the file owners with a single command. 

rsync --archive --chown=bishrulhaq:bishrulhaq ~/.ssh /home/bishrulhaq
 

Setting Up a Firewall with UFW

Uncomplicated Firewall (UFW) is an interface to iptables that is designed to simplify the process of configuring a firewall and it is used to allow connections to specified services.

 

Type the following command to check the list of profiles registered with UFW.

ufw app list
 

It will return with the list of available applications and I’m going to allow OpenSSH by typing the following command.

ufw allow OpenSSH

 

Then, You can enable the firewall by typing the command.

ufw enable

 

Check the status of allowed connections by typing:

ufw status

 

The firewall will block all the connections except the one you have allowed. If you install any new services you need to allow the connection in order to use it.

 

 

Hope this article helped you 😊. If you like this please share with others and drop your ideas and suggestions at the comment section.

Share:

Related Post

How to install WordPress with Nginx on Ubuntu 18.04

In this tutorial you’ll learn to set up WordPress the most popular CMS (content management system) on ubuntu 18.04.

  • 4 years ago

Installing Nginx, PHP, MySQL and PHPMyAdmin on Ubuntu 18.04

This tutorial is created to set up Nginx and PHPMyAdmin along with PHP 7.4 on ubuntu 18.04 with simple and easy steps.

  • 4 years ago