What you should do after getting your Virtual Private Server(VPS)?

What is VPS?

Today we are going to talk about your first steps after purchasing a VPS. VPS is a virtual server that runs a copy of an operating system. In many ways, it works similar to a physical dedicated server, being actually a piece of software that resides within a parent serve, shared by multiple customers. Its work is provided by virtualization technology. Unlike shared hosting, you have allocated resources, so that other companies do not affect your performance.

Choosing a hosting provider

When purchasing a VPS, the first step you make is choosing a hosting provider. You should choose carefully, since different providers offer different solutions, that vary in performance, storage, RAM, etc. To find an optimal solution, analyze the purposes you need a VPS for, e.g. the software you are going to use on it. Smaller projects which don’t need too much software will be alright with only 512 MB of RAM. Bigger projects require more capacities.

Check out HostZealot VPS Europe. They offer 7 locations to choose from covering the majority of Europe, SSD/NVME hard drives, and provisioning within minutes. 

After choosing a hosting provider

After choosing a hosting provider and purchasing a VPS, you’ll get an email with all the basic information about the server. There you’ll find IPv4 and IPv6-address of the VPS, username, and SSH password.

A fast and secure way for installing and setting up the VPS is to use Secure Shell (SSH).

To finish the installation, enter:

ssh root@??.??.???.???

Instead of ??.??.???.??? you should write your IPv4 address.

Enter the password. After this, you’ll see a greeting screen. Now the VPS is installed. Let’s move on to the VPS setup.

Basic VPS setup

Basic VPS consists of a few regular steps, so you can perform them yourself, without the help of a specialist.

The first one is changing the Root password. To do it, enter the passwd command. It will request a new password. To check it, exit the connection and connect again.

Other basic settings include changing the time zone, creating a new user, updating the kernel, reassignment of the Root rights. We’ll talk about them later. First, before configuring this basic setting, you have to protect your VPS from hacking. To do it, change the default port and install the firewall.

Changing the default port

The default port value for a VPS is usually 22 and for security, it’s usually changed. However, when purchasing HostZealot VPS, you don’t need to care about it since they have done it for you – the port number is 56777.

However, if you wish, you can still change the port. To do so, open the SSH configuration file with the following command:

nano /etc/ssh/sshd_config

Change the value of Port variable to any number between 1 and 65535.

Then restart the SSH service with the commands:

service ssh restart (for Debian/Ubuntu);

service sshd restart (for CentOS);

To check if the operation succeeded, start another SSH session with new settings.

Firewall setup

In this article, we are going to see how to install the UFW firewall. There are other firewalls as well, but this particular one is provided with iptables interface, which is known for being simple and easy to use. 

To install it, use the command:

sudo apt install ufw

When installed, the firewall will block any incoming connection by default. Therefore you need to allow incoming connections to SSH server before turning UFW on. Use the command:

sudo ufw allow 44933/tcp

To check, you have to make sure whether the port corresponds to the listener port of SSH server with the command:

sudo ufw show added

Turn on UFW:

sudo ufw enable

Check the current active rules:

sudo ufw status

Exit the SSH connection and then restore it. Now the VPS server is installed and protected.

Adding new user

It’s recommended to add new users during VPS installation to limit the access rights and exclude unauthorized access to the system.

First, connect to the VPS. It’s better to do it via SSH. Run the command of adding a new user:

$ sudo adduser <username>

Now check:

$ su — username

You’ve just created a new user with limited sudo rights. You can allocate admin rights to non-root users too. We’ll talk about it later. If there are many users, it’s recommended to check the rights settings from time to time. To do so, use the following command:

sudo dpkg-reconfigure tzdata

Rebuilding the kernel

After installing and basic setup of the VPS, you may need to update the kernel to its final version. Let’s see how it works for Linux.

First and the server as Root user with your general SSH client.

Update

You have to update the Ubuntu repository and all of its packages:

sudo apt-get update

sudo apt-get upgrade -y

Restart the server:

sudo reboot

Check for updates:

sudo apt list –upgradeable

You should see the following text:

root@server2:~# sudo apt list –upgradeable

Listing… Done

root@server2:~#

Active kernel version

To check the current kernel version, enter the command:

uname -r

You’ll see:

root@kernelUpgrade:~# uname -r

4.4.0-143-generic

root@kernelUpgrade:~#

4.4. here is the current kernel version. After the update, you can check whether the version has changed with the same command.

Installing new kernel

Create a folder for the new kernel version, make it a working folder. In this example we are going to install the 4.11.2: version:

sudo mkdir -p ~/4.11.2

cd ~/4.11.2

Download the necessary version packages. To do so, perform the following commands:

wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.11.2/ linux-headers-4.11.2-041102_4.11.2-041102.201705201036_all.deb

 

wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.11.2/ linux-headers-4.11.2-041102-generic_4.11.2-041102.201705201036_amd64.deb

 

wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.11.2/ linux-image-4.11.2-041102-generic_4.11.2-041102.201705201036_amd64.deb

Then install the downloaded packages through dpkg:

dpkg -i *.deb

After the installation restart grub:

sudo update-grub

There is a common problem that “the update grub command is not found”. You can solve it with the following command:

sudo apt-get install –reinstall grub

After the successful update, restart the server:

sudo reboot

Check the server version:

uname -r

You should see the following text:

root@kernelUpgrade:~# uname -r

4.11.2-041102-generic

root@kernelUpgrade:~#

Conclusion

In this article, we’ve covered some basic steps of starting to work with a newly purchased VPS. You’ll learn more about VPS its setup in our following posts. Stay tuned and have a nice day!

 

Learn more about VPS:

https://www.digitalocean.com/community/tutorials/initial-server-setup-with-ubuntu-20-04

http://flsilva.com/blog/how-to-securely-set-up-vps-server-tutorial-ubuntu-and-debian/