Skip to content

VPS Setup

Linux VPS (Virtual Private Server) Setup notes.

Connecting to Server

Connect to server with SSH

Terminal window
ssh root@12.13.14.15

It will prompt to add fingerprint. Type yes and it will ask for password.

To exit from the ssh session we just need to simply type:

Terminal window
exit

Update and Upgrade packages

Terminal window
sudo apt update
Terminal window
sudo apt upgrade

You may need to reboot the server after updating some packages or kernel upgrade.

To check if the server needs reboot, run the following command:

Terminal window
ls /var/run/reboot-required

Restart the ssd service

If we change the ssh configuration, we need to restart the ssh service daemon.

Terminal window
sudo service ssh restart
Terminal window
sudo systemctl restart sshd

Securing the Server

Check login attempts

Terminal window
tail -n 10 -f /var/log/auth.log

Change the user password

Terminal window
passwd

Login with SSH

Terminal window
cat ~/.ssh/id_ed25519.pub

Copy the ssh public key and add the value on the server’s ~/.ssh/authorized_keys file.

After that SSH promts should not ask for password and directly login.

If the SSH login is not working on the server, check /etc/ssh/sshd_config file and make sure PubkeyAuthentication is enabled.

Disable password login

Terminal window
sudo nano /etc/ssh/sshd_config

Change the PasswordAuthentication value to no

Terminal window
PasswordAuthentication no

Disable root login

Set the value of PermitRootLogin to no in ssh config file

Terminal window
sudo nano /etc/ssh/sshd_config
Terminal window
PermitRootLogin no