Grid Guides

Explore How System On Grid Can Work For You

Grid Guide Topics

How to do Initial Server Setup with Ubuntu 18.04

Table Of Contents


    ## Table of Contents

    – [Introduction](#introduction
    – [Prerequisites](#prerequisites
    – [Log into Root User Account](#log-into-root-user-account
    – [What is a Root](#what-is-a-root
    – [Create a New User Account](#create-a-new-user-account
    – [Give Root Privileges to the New User Account](#give-root-privileges-to-the-new-user-account
    – [Setup a Basic Firewall](#set-up-a-basic-firewall
    – [Enable External Access for your Regular User](#enable-external-access-for-your-regular-user

    ## Introduction

    In this guide, we are going to tell you the step-by-step process you should follow for initial server setup with Ubuntu 18.04. There are a few simple steps that you need to follow initially as basic server setup. The best part about setting up your server with Ubuntu 18.04 – It will increase the usability and security of your server and make it run for your intended purposes.

    ## Prerequisites

    A Running Orbit

    ## Log into Root User Account

    If you want to log into your server, you need your server’s IP address and the password to your root account.

    After knowing them, you can log into your server with the following command.
    “`
    $ ssh demo@192.168.32.76
    “`
    Don’t get frightened, if you see the following message. You received this message because you are connecting to your Ubuntu server for the first time. And, the computer is telling you that it doesn’t recognize the remote server.

    ![rootuseraccount](https://grid.media/assets/images/Root-user-account.png

    To confirm your authentication, just type ‘Yes’.

    ## What is a Root

    In Linux terminology, a Root is an administrative user with many privileges. But, you are not supposed to use it regularly. This is because of the very broad privileges of the root account and also the ability of it to make hostile changes (accidentally.

    ## Create a New User Account

    You need to create a New User Account (An Alternative User Account just to avoid the possibility of making hostile changes to your account.

    After logging into the root account using the below command, we will be prepared to add an alternative account which you can use to login from now on.
    “`
    $ sudo su
    “`
    I am creating a new user called ‘demo’. Replace ‘demo’ with any other name that you wish to add.
    “`
    #adduser demo
    “`
    After that, you are asked to answer a few questions, starting with your account password.

    It is always recommended to give a strong password. You can also give additions information if you want to, otherwise just click on the ‘ENTER’ button.

    ## Give Root Privileges to the New User Account

    At present, the new user account has some basic account privileges. Despite that, we need to do a few administrative tasks.

    To use root privileges, you can not always log out the new user account and log into the root account. So, we set up a ‘superuser’ or the root privileges to your new user account. This will allow the new user to use administrative privileges and run commands by adding the word ‘sudo’ before each command
    “`
    # usermod -aG sudo demo
    “`
    Now, the new user can use the account with the root privileges.

    ## Setup a Basic Firewall

    An Ubuntu 18.04 server uses [UFW firewall](https://systemongrid.com/support/guides/how-to-setup-a-firewall-with-ufw-on-an-ubuntu-and-debian-cloud-server to make sure that the connections to certain services are allowed. You can set up the basic firewall using this application.

    Upon installing UFW, different applications can register their profiles. These profiles allow UFW to manage different applications by their names.
    Now, OpenSSH, a service that allows us to connect to our servers, also has a profile registered with UFW.

    You can check this using the below command.
    “`
    # ufw app list
    “`

    Output:

    ![](http://

    You must make sure that the firewall is allowing [SSH connections](https://systemongrid.com/support/guides/understanding-the-ssh-encryption-and-connection-process so that we can log in back in next time.

    We can allow these connections by using the below command.
    “`
    # ufw allow openSSH
    “`
    We can enable the firewall by using the command:
    “`
    # ufw enable
    “`
    Type ‘Y’, press ENTER to continue.

    Use the below command to see what SSH connections are still allowed.
    “`
    # ufw status

    “`

    output:

    ![](http://

    The firewall is currently blocking all connections except for SSH. If you install and configure some additional services, you will need to alter the firewall settings to allow the acceptable traffic in.

    ## Enable External Access for your Regular User

    Now, you have a new user with Root privileges for daily use. It’s time to choose whether to log into your account using a password or SSH keys authentication.

    ## If you use Password Authentication

    If you log into the root account using the password authentication, you can log into your new user account by opening a new terminal and using SSH with your new user account.
    “`
    $ ssh demo@192.168.32.76
    “`
    Then, you are prompted for the new user’s password that you configured. After this, you can log in as a new user.

    And, if you want to run a command with the root privileges, you need to type sudo before it.
    “`
    $ sudo command_to_run
    “`
    If everything is alright, you can exit your sessions by typing
    “`
    $ exit
    “`
    ## If you use SSH Keys Authentication

    If you log into the root account using SSH keys, the password authentication will be disabled for SSH.

    You need to add your public key to the ~/.ssh/authorized_keys file in your new user account.

    As your public key is already in ~/.ssh/authorized_keys file in your new user account, copy that file and directory structure to your new user account.

    You can use rsync command to copy the files with the correct ownership and permissions. The command will copy the root user’s .ssh directory, preserve the permissions, and change the file owners.

    And, don’t forget to change the highlighted portions of the command to match your new user account.
    “`
    $ rsync
    “`
    Then, open a new terminal session using ssh with your new username.
    “`
    $ ssh demo@192.168.32.76
    “`
    you must be logged into the new user account without the password authentication. And, if you want to run a command with the root privileges, you need to type sudo before it.
    “`
    $ sudo command_to_run
    “`
    If everything is alright, you can exit your sessions by typing
    “`
    $ exit
    “`