Setting up an Ubuntu server

For future reference. Taken from here, shortened version.

      ##### Create a user
      adduser sammy
      usermod -aG sudo sammy

      ##### Copy ssh keys
      su - sammy
      mkdir ~/.ssh
      chmod 700 ~/.ssh
      vim ~/.ssh/authorized_keys
      # Insert public key from the local machine, cat ~/.ssh/id_rsa.pub
      chmod 600 ~/.ssh/authorized_keys
      exit

      ##### Disable password authentication
      sudo vim /etc/ssh/sshd_config
      # Set: PasswordAuthentication no, PubkeyAuthentication yes, ChallengeResponseAuthentication no
      sudo systemctl reload sshd

      ##### Upgrade and install packages
      sudo apt-get update
      sudo apt-get upgrade
      sudo apt-get install python3-pip python3-dev libpq-dev postgresql postgresql-contrib nginx

      ##### Firewall
      sudo ufw allow OpenSSH
      sudo ufw enable
      # Good time to check ssh connection works
      

11 Mar 2022