Initial server setup with centos 7

This article will discuss important tasks to perform in the server for the initial setup with Centos 7 and some basic server security.

CentOS, or the Community Enterprise Operating System, is a popular Linux distribution. It’s derived from, and is fully compatible, with Red Hat Enterprise Linux.

CentOS 7 will enjoy support until the end of 2020 and will receive maintenance updates until the end of June 2024.

Initial server setup with Centos 7

Root login on Centos 7

If you aren’t connecting to your server, log in as the root by the following command:


Accept the warning about host authenticity, and if it appears, then provide your root authentication. If it is your first time logging into the server, you should change the root password with a new password.

Point: We suggest choosing a complex password, including letters, numbers, and symbols.

Create a new user on Centos 7

You can create a new user by the adduser command on Centos 7, for example: create a user named Orcacore:

adduser orcacore

Create a password for your user by using this command:

passwd orcacore

Choose a strong password for it.

Root privileges on Centos 7

In the basic server setup on Centos 7 if a normal user wants to use the administrative privileges should put sudo before each command.
To add these privileges to our new user, we need to add the new user to the “wheel” group. By default, on CentOS 7, users who belong to the “wheel” group are allowed to use the sudo command.
You can add your new user to the “wheel” group with the following command:

gpasswd -a orcacore wheel

Add public key authentication for server setup

In the initial server setup with Centos 7, you should secure your server by setting up public-key authentication for your new user.
This security requires a private SSH key to log in.
If you already have a public key that you want to use, skip to the Copy the Public Key step. You can generate your new pair (public/private) key by visiting the How to generate SSH key pair article.
After this, you should copy your public key to your new server. You can do this in two ways:

1) Use ssh-copy-id

ssh-copy-id orcacore@SERVER_IP_ADDRESS

2) Manually install the key

cat ~/.ssh/

In your output, you will see your public SSH key, select and copy it.
After this, you should add the public key to your new remote user with the following commands:

su – orcacore

Create a new directory and set its permissions on Centos 7:

mkdir .ssh
chmod 700 .ssh

Then open a file with the vi editor (or your favorite) named authorized_keys:

vi .ssh/authorized_keys

Enter your public key in your editor save and close the file.
Set permissions for authorized_keys:

chmod 600 .ssh/authorized_keys

Type this command once to return to the root user:


Configure SSH daemon to disallow root login with password

Now that we have our new account, we can secure our server by modifying its SSH daemon configuration to disallow remote SSH access to the root account.
First, open the configuration file with vi editor as root on centos 7:

vi /etc/ssh/sshd_config

In your text editor find the” PermitRootLogin yes ” line and add # at the beginning of the line. Then replace no with yes. like the below picture.

Then save and close the file by pressing the Esc button and typing the “:wq” and pressing the Enter button on your keyboard.

permit root login deny

After that reload the SSH service with the below command:

systemctl reload sshd

Now you should test your new configuration.
Open a new terminal window and run this command:

ssh orcacore@SERVER_IP_ADDRESS

Conclusion of initial server setup Centos 7

At this point, you learn a basic server setup on centos7 and some basic server security for it.

I hope you enjoy this article about the initial server setup with Centos 7.

Also if you need to see and learn more Tutorials about CentOS 7, you can follow CentOS 7 Tutorials.

Newsletter Updates

Enter your email address below and subscribe to our newsletter

Stay informed and not overwhelmed, subscribe now!