Lewis Callow

Building and hardening my first Linux server

Tonight I went through steps 1 to 3 of creating a Linux VM with Multipass and hardening it with a firewall and key-only SSH.

This is my first project in a series to learn Linux properly, so I can work on real systems.

The steps

  1. Privileged user creation. An admin account used for everything from here on.
  2. SSH hardening. Key-only login, so no password authentication, and root login disabled.
  3. Firewall. Default deny incoming, allow outgoing, and open up ports 22 (SSH), 80 (HTTP) and 443 (HTTPS).

What I learnt

  • ls -la shows hidden files.
  • su can be used to switch user.
  • chmod is how you set permissions on folders and files. This is especially important because SSH can ignore your key if the permissions are too open.

Mistakes

  • Looking in the wrong place for keys. I went to /etc/ssh and found the server's host keys. I later found out that host keys prove the server's identity, and user keys prove mine.
  • Making authorized_keys a folder. I used mkdir instead of creating a file.
  • Pasting an incomplete key from my Mac. I missed out the ssh-rsa at the start of the key.
  • My sudo wasn't actually working. I created the user with sudo adduser lewisadm. I then needed sudo usermod -aG sudo lewisadm to add it to the sudo group.

Next

Part two: installing nginx to serve a page, then digging into logs and setting up fail2ban.