VPS Setup
Linux VPS (Virtual Private Server) Setup notes.
Connecting to Server
Connect to server with SSH
ssh root@12.13.14.15It 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:
exitUpdate and Upgrade packages
sudo apt updatesudo apt upgradeYou may need to reboot the server after updating some packages or kernel upgrade.
To check if the server needs reboot, run the following command:
ls /var/run/reboot-requiredRestart the ssd service
If we change the ssh configuration, we need to restart the ssh service daemon.
sudo service ssh restartsudo systemctl restart sshdSecuring the Server
Check login attempts
tail -n 10 -f /var/log/auth.logChange the user password
passwdLogin with SSH
cat ~/.ssh/id_ed25519.pubCopy 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
sudo nano /etc/ssh/sshd_configChange the PasswordAuthentication value to no
PasswordAuthentication noDisable root login
Set the value of PermitRootLogin to no in ssh config file
sudo nano /etc/ssh/sshd_configPermitRootLogin no