Renting a VPS server is a good way to start a professional web presence. Once you’ve realized that VPS is exactly what you need, it’s time to opt for the right operating system for it. A common good option among hosters is Ubuntu.
Ubuntu is one of the common OS Linux distributions that is specially optimized to manage a multi-server infrastructure. It’s also distinguished with stability, regular security updates, extensive ROOT level administration rights, and, of course, it’s free of charge, so don’t hesitate when choosing Ubuntu VPS hosting Hostzealot.
However, purchasing an Ubuntu VPS is only the first step, because at the beginning you have just the bare operating system and in order to make it work according to your needs, you’ve got to set it up first. So, in today’s short guide we are going to look at the basic and most important steps of setting up your Ubuntu VPS, namely the users’ setup, SSH, as well as the firewall setup.
1. Updating the system
The first step after installing any software is updating the operating system. To perform it, you’ll need the following commands:
$ sudo apt update
sudo apt list –upgradable
$ sudo apt upgrade
The older the installation file of your Ubuntu Server is, the more time the installation will take. But for anything to run, this procedure is necessary, you will need to wait a bit.
2. SSH update
A server system requires remote access. Therefore it is necessary to set up the SSH protocol after the update to use it for further setup.
First, for the sake of security, you need to change the SSH port on the remote server. To do so, open the /etc/ssh/sshd.conf, find the Port 22 line and change the port value to any other number:
$sudo vi /etc/ssh/sshd_config
Port [your number]
To run the SSH service and add it to auto download, use the following command:
$ sudo systemctl start sshd
$ sudo systemctl enable sshd
The above-mentioned operation allows you to log in from another device right now. But if you don’t want to write the password each time you log in, you can set up log-in with a key. To do so, use the following command to generate the key on your device:
Then choose the directory the key is to be saved to. You can choose something like ~/.ssh/id_rsa_ubuntu etc. You can also create a password for the key. If you don’t want to enter it every time you log in through SSH, you can leave the field blank. However, if the security is rather important to you, you shouldn’t use keys without passwords.
After it, send the newly created key to your server:
$ ssh-copy-id -i ~/.ssh/id_rsa_ubuntu.pub [email protected]
To log in to your server without a password, use the following command:
$ ssh [email protected]
The further server setup can be done via SSH.
3. Firewall Setup
To protect the server in the network, you have to hide the running services with the firewall. For configuring the firewall on Ubuntu, you will need the UFW, a firewall configuration tool developed to ease iptables firewall configuration.
The firewall is responsible for denying access to all external services that aren’t authorized. Since we work through SSH, we have to allow this service:
$ sudo ufw allow OpenSSH
If in the second step you’ve changed the port, so you have to specify your new port:
$ sudo ufw allow [your port]/tcp
Then execute the following command for turning on ufw:
$ sudo ufw enable
After that press y to run the firewall and add it to auto download. To check its status, use the following command:
$ sudo ufw status
4. Time setup
The installer doesn’t offer you to choose the time zone by default. To check, which time is now, use the following command:
If you need to change the timezone, add your own timezone. To check the list of available timezones, use the following command:
$ timedatectl list-timezones
To choose the timezone you need, enter:
$ sudo timedatectl set-timezone [your timezone]
To set up the automatic synchronization with servers on the internet, set up NTP server. To do it, enter:
$ sudo apt install ntp
Then, add it to auto download:
$ sudo systemctl enable ntp
5. Unblocking ROOT user
In Ubuntu, there is no superuser password by default. If you want to login into the system as a superuser, because you need it to manage the configuration system etc, you have set up a password for it:
$ sudo passwd root
Enter the new password. Now you can log in as this user:
$ su – root
In this short guide we’ve gone through the basic steps of Ubuntu VPS configuration. Of course, to get the whole use of your Ubuntu VPS, you should do a lot more things. It’s impossible, however, to comprehend all of them in one single article, so this one will not be the last one. Stay tuned!