Initial Server Setup with CentOS 8

When you first create a new server, there are a few configuration steps that you should take early on as part of the basic setup.

In this tutorial we will configure your new CentOS 8.

Create a Sudo User

Step 1 : We can add a user to the system using useradd from the command line with a simple command, as follows:

useradd devtutorial

Step 2 : Next, we add a password for the user using the command:

passwd devtutorial

Enter a password, and repeat it again to verify it.

Step 3 : Add the new user devtutorial to the wheel group using the usermod command. By default, on CentOS 8, users who belong to the “wheel” group are allowed to use the sudo command.

usermod -aG wheel devtutorial

Step 4 : We can now switch to our new account devtutorial

su - devtutorial

Step 5 : Open a new terminal window. Go ahead and log in as the devtutorial user using the following command

ssh devtutorial@SERVER_IP_ADDRESS

Disable SSH Root Login

Now that we have our new account, we can secure our server by disabling remote SSH access to the root account.

Step 1 : Opening the configuration

sudo vi /etc/ssh/sshd_config

Step 2 : In this file, search for the line “PermitRootLogin” and update the line to look like in the below file excerpt.

PermitRootLogin no

Enter :x! then ENTER to save and exit the file.

Step 3 : Now that we have made our changes, we need to restart the SSH.

sudo systemctl reload sshd

Enable Firewall in CentOS 8

Firewalld is the main firewall utility that uses interacts with in order to manage iptables rules.

Step 1 : If you are connected via SSH, you need to make sure that the server firewall allows web access.

sudo firewall-cmd --add-service=ssh --permanent

Step 2 : To enable and start and verify the firewall in CentOS 8, run:

sudo systemctl enable firewalld
sudo systemctl start firewalld
sudo systemctl status firewalld

Update CentOS 8 System

Step 1 : To fully update a CentOS 8 system, Run the following string of commands to check, download and install the latest packages.

sudo yum check-update
sudo yum upgrade -y

Step 2 : Package manager cleanup

sudo yum clean all

Install System Utilities

To install the Nano text editor on CentOS 8, run this command:

sudo yum install nano -y

Type the following command to install wget

sudo yum install wget -y

Add Comment