How to set up a server for the first time

Basic steps to do after creating an Ubuntu VM.

Login as root:

ssh root@$USERNAME

Create new user:

adduser $USERNAME

Granting administrative privileges:

usermod -aG sudo $USERNAME

Set basic firewall:

ufw allow OpenSSH
ufw enable
ufw status

Enable external access to our user (assuming the root account uses SSH key authentication):

rsync --archive --chown=$USERNAME:$USERNAME ~/.ssh /home/$USERNAME
Tags: