First 10 Minutes On A (Ubuntu) Linux Server

Securing Ubuntu

I’ve been meaning to write a post for a while now about setting up a (Ubuntu) Linux server from scratch. I recently found a post, so I will just link to it instead.

My First 10 minutes on a server by Cody Littlewood.

Cody talks about adding users, SSH keys, setting up a firewall etc. well worth reading and bookmarking.

My Version

apt update && apt upgrade
apt install ufw
ufw allow ssh
ufw enable
ufw status
export USERNAME=newuser
useradd $USERNAME
mkdir -p /home/$USERNAME/.ssh
chmod 700 /home/$USERNAME/.ssh
usermod -s /bin/bash $USERNAME

On another machine generate a new SSH key pair:

ssh-keygen -t rsa -b 4096 -C ""

Add the public key to the server

vim /home/$USERNAME/.ssh/authorized_keys
chmod 400 /home/$USERNAME/.ssh/authorized_keys

Update the password and enable access to run sudo.

passwd $USERNAME

Make sure the following lines are there:

root    ALL=(ALL) ALL
%sudo   ALL=(ALL:ALL) ALL

Then add the user to the group.

usermod -aG sudo $USERNAME