Advance

Initial Setup With Ubuntu 18.04

Initial Setup with Ubuntu 18.04
0
(0)

To start learning Initial Setup with Ubuntu 18.04 it is worth mentioning that there are a few configuration steps that you should take early on as part of the basic setup. To increase the security and usability of your server, you may decide to create a new Ubuntu 18.04 and let your system to have a solid foundation for subsequent actions.

To let your studies work better, choose your own Ubuntu VPS Server with instant activation.

 

 

Initial Setup With Ubuntu 18.04

Let’s walk through the steps of this tutorial to review the Initial Setup with Ubuntu 18.04. In case you are interested in learning the initial setup of the latest version, find our article on the Initial server setup on Ubuntu 20.04.

 

Step 1: How To Log In As Root

It is clear that you need to know your IP address to be able to log into your server. In case you have installed an SSH key for authentication, you need the private key for the root user’s account or the password. But if this is the first time you are connecting to your server, you should log in as the root user. To go ahead, run the following command:

ssh root@your_server_ip

Point: Substitute the (your_server_ip) of the command with your server’s public IP address.

In case you faced a host authenticity warning, accept it, and provide your root password to log in if you are using password authentication.

Also, you would be forced to enter the passphrase the first time you use the key each session if you are using an SSH key that is passphrase protected. You can guess that if you are not already connected to your server, you may also be prompted to change the root password.

Recommended Article: What is a Virtual Private Server?

What Is Root

An administrative user who has very broad privileges in a Linux. But you may be discouraged from using it on a regular basis because of its boosed privileges.

But there is another way to go!

You can set up an alternative user account with a reduced scope of influence for day-to-day work. So keep continuing reading this article to see how to gain increased privileges any time it is necessary.

 

 

 

Step 2: How To Create A New User

You would be ready to add the new user account which you will use to log in from now on, after logging in as root. To see how to create a new user, have a look at the below example.

Point: In this article, the user is called noodi, remember to replace it with your preferred username.

adduser noodi

At this point, you should answer some questions, first for the account password.

Do not forget to choose a strong password. To be more secure, fill in the additional information even they are not required. Also, you can hit ENTER in any field you wish to skip.

 

 

Step 3: How To Gran Administrative Privileges

Since you have a new user account with regular account privileges, you may sometimes need to do administrative tasks. Try to set up what is known as “superuser” or root privileges for our normal account, to plan to avoid the logging out of your normal user and log back in as the root account. In this way, you would let your normal user run commands with administrative privileges by putting the word sudo before each command. Once you add these privileges to your new user, adding a new user to the sudo group is required. In conclusion, users who belong to the sudo group on Ubuntu 18.04, are allowed to use the sudo command by default.

To add your new user to the sudo group, type the command below as root.

usermod -aG sudo noodi

Point: Substitute ”noodi” with your new user.

If you want to perform actions with superuser privileges,

type sudo before commands after login as your regular user.

 

 

 

Step 4: How to Set Up a Basic Firewall

Since Ubuntu 18.04 servers use the UFW firewall, you can set up a basic firewall very easily using this application to make sure only connections to certain services are allowed.

Different applications can register their profiles with UFW upon installation. These profiles allow UFW to manage these applications by name. OpenSSH, the service allowing us to connect to our server now, has a profile registered with UFW.

You can see this by typing:

ufw app list
Output
Available applications:    OpenSSH

 

Then, you need to make sure that the firewall allows SSH connections so that you can log back in next time. Use the following command to allow these connections:

ufw allow OpenSSH

Afterward, enable the firewall using the command below:

ufw enable

Type “y” and press ENTER to proceed. You can see that SSH connections are still allowed by typing:

ufw status
Output
Status: active    To                         Action      From  --                         ------      ----  OpenSSH                    ALLOW       Anywhere  OpenSSH (v6)               ALLOW       Anywhere (v6)

 

From now on, you need to adjust the firewall settings to allow acceptable traffic in because the firewall is currently blocking all connections except for SSH

 

Step 5: How To Enable External Access For Your Regular User

Till here, you have a regular user for daily use. So, ensure that you can SSH into the account directly. Depends on whether your server’s root account uses a password or SSH keys for authentication, you can see the process of configuring SSH access for your new user.

Please Note: You are recommended you to stay logged in as root until you ensure that you can log in and use sudo with your new user. The reason is to let you troubleshoot and make any necessary changes as root, anytime you face a problem.

 

 

 

If the Root Account Uses Password Authentication

If you logged in to your root account using a password, then password authentication is enabled for SSH. You can SSH to your new user account by opening up a new terminal session and using SSH with your new username:

ssh noodi@your_server_ip

After entering your regular user’s password, you will be logged in. Remember, if you need to run a command with administrative privileges, type sudo before it like this:

sudo command_to_run

You will be prompted for your regular user password when using sudo for the first time each session (and periodically afterward).

To enhance your server’s security, we strongly recommend setting up SSH keys instead of using password authentication.

 

Recommended Article: Initial Setup With Ubuntu 18.04

If the Root Account Uses SSH Key Authentication

If you logged in to your root account using SSH keys, then password authentication is disabled for SSH. You will need to add a copy of your local public key to the new user’s ~/.ssh/authorized_keys file to log in successfully.

Since your public key is already in the root account’s ~/.ssh/authorized_keys file on the server, you can copy that file and directory structure to our new user account in our existing session.

The simplest way to copy the files with the correct ownership and permissions is with the rsync command. This will copy the root user’s .ssh directory, preserve the permissions, and modify the file owners, all in a single command.

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

Note: Do not forget to replace noodi:noodi with your regular user’s name.

Please Note: The rsync command treats sources and destinations that end with a trailing slash differently than those without a trailing slash. When using rsync below, be sure that the source directory (~/.sshdoes not include a trailing slash (check to make sure you are not using ~/.ssh/).

If you accidentally add a trailing slash to the command, rsync will copy the contents of the root account’s ~/.ssh directory to the sudo user’s home directory instead of copying the entire ~/.ssh directory structure. The files will be in the wrong location and SSH will not be able to find and use them

 

Now, open up a new terminal session and using SSH with your new username:

ssh noodi@your_server_ip

You should be logged into the new user account without using a password. Remember, if you need to run a command with administrative privileges, type sudo before it like this:

sudo command_to_run

You will be prompted for your regular user password when using sudo for the first time each session (and periodically afterward).

Conclusion

In this article, you learned about Initial Setup with Ubuntu 18.04 and now you have a solid foundation for your server. You can install any of the software you need on your server now. To get more involved with the subjects you learned in this guide, have a look at our articles on Install SSH Server on Linux and allow root user login AND Tutorial connect to ssh on linux.

How useful was this post?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate this post.

View More Posts
Marilyn Bisson
Content Writer
Eldernode Writer
We Are Waiting for your valuable comments and you can be sure that it will be answered in the shortest possible time.

10 thoughts on “Initial Setup With Ubuntu 18.04

    1. It is a good idea to do this optional step as a good security aspect. Use the command below to do this.
      sudo nano /etc/ssh/sshd_config

    1. The best situation is if your server operates be in the same timezone as you are. To see the list, type the following command:
      timedatectl list-timezones

    1. First, you need to check the current status of the SSH root login by using the following command:
      sudo cat /etc/ssh/sshd_config | grep PermitRootLogin

Leave a Reply

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

We are by your side every step of the way

Think about developing your online business; We will protect it compassionately

We are by your side every step of the way

+8595670151

7 days a week, 24 hours a day