blog posts

9 things to do after buying a CentOS VPS

There are some important steps to take to set up a VPS after purchasing it: increase security and make it easier to use. This post will review some things to do after purchasing any VPS.

We assume the VPS is running on Centos, so that we will use the commands and file paths in the Centos-based terminal for this tutorial. But you can use the same instructions with a little change on other Linux distributions.

1. System update

After purchasing a new VPS and setting it up, updating all available packages before you even start using it is important. In centos, this can be done by running a simple command.

yum update -y

2. Change hostname

It’s usually hard to remember the default hostname that a VPS comes with. Ideally, a hostname is supposed to be a reference to an IP address. So that we use the hostname instead of the IP address to access the server. So we need to change the hostname to something we will remember and have no problem using otherwise we will defeat this logic.

The first step is to create a record of your hostname. Then add it as follows from the terminal:

hostnamectl set-hostname serv.domain.tld

3. Changing time and time zone

The third important step after purchasing a VPS is to set the time zone to the local time for reporting.

Learning to change the time zone in Ubuntu in 2 ways

You can update the time zone using the following command:

timedatectl set-timezone Europe / Australia

You can also synchronize your time with a local ntp time server. For example, for Kenya, we can use 0.ke.pool.ntp.org.

yum install -y ntpdate

ntpdate 0.ke.pool.ntp.org

You can check your local ntp server here.

4. Install useful applications

vim and wget tools and epel repository are among the most useful things used by sysadmins in Linux servers.

yum install -y vim wget screen epel-release

5. sudo config

Disabling root access to the server is the usual method. This means you don’t need to configure another username to use remote login. You want to be able to use sudo with such a user, so you need to configure the user to be a sudoer as well. Run the following command to create a user named reza.

useradd reza

usermod -aG wheel reza

Then add the following line in the sudoers file, which you can access by typing visudo.

reza ALL=(ALL) NOPASSWD:ALL

6. Change the SSH port from the default mode

Changing the default SSH port is an important step in securing your server against brute-force attacks. You can skip all the steps mentioned before and after this step, but never fail to change your SSH port. It is better to choose a port greater than 1000 because most of the following ports are already assigned to various common services.

Enter this page to read the full tutorial on changing the SSH port.

7. Configure ssh key login

Using SSH keys to log in is more convenient and secure than password authentication. To do this, you need to configure the ssh config file.

Enter this page to see the full SSH click change tutorial.

8. Update users’ passwords

Change the password your VPS provider sent you to something different.

paswd

Expenditure of the above code:

Changing password for user root.

New password:

Retype new password:

9. Installing a firewall

All servers accessible to the Internet require a firewall. It doesn’t matter what you use. But we suggest you CSF firewall. Therefore, if you already have a firewall installed on your server, remove it, then install csf.

cd /usr/src; rm -fv csf.tgz; wget https://download.configserver.com/csf.tgz; tar -xzf csf.tgz;cd csf; sh install.sh

After that, remember to remove csf from TESTING mode by setting TESTING = 0 in the /etc/csf/csf.conf file. Then enable lfd so that they start automatically whenever the system reboots.

systemctl enable lfd

Conclusion

The above are the most important points after purchasing a VPS, and after doing them, you can use the VPS with ease.