skip to content
System Design in the Smoking Room
(AI translated)

A mini cheat sheet for setting up Ubuntu Server

/ 1 min read

Table of contents

I keep forgetting and googling the stuff I need to set up my VMs. Right now I’m setting up Klipper again, so these commands are suddenly relevant again.

Users

A new user

Terminal window
sudo adduser <username>

Add them to sudo

Terminal window
sudo usermod -aG sudo <username>

Sudo without a password

Terminal window
sudo visudo
# At the very bottom of the file
<username> ALL=(ALL) NOPASSWD: ALL

SSH

Generating a key

Terminal window
ssh-keygen -f ~/.ssh/<filename> -t ed25519

Copying the key over

Terminal window
ssh-copy-id -i ~/.ssh/<filename> <user>@<address>

sshd config for key-based login

Open the config itself:

Terminal window
sudo nvim /etc/ssh/sshd_config

In the config:

  • Ban root:
Terminal window
PermitRootLogin no
  • Turn off password login:
Terminal window
PasswordAuthentication no
  • Disable interactive passwords:
Terminal window
KbdInteractiveAuthentication no
  • Enable key-based access:
Terminal window
PubkeyAuthentication yes

After that, restart sshd on the server:

Terminal window
sudo systemctl restart sshd

To make sure password login no longer works, run:

Terminal window
ssh -o PreferredAuthentications=password <user>@<address>

You should get back:

Terminal window
<user>@<address>: Permission denied (publickey).

Bells and whistles

This is where I’ll keep adding things I like having on a box, either to make work easier or just for the looks.

Starship

Terminal window
curl -sS https://starship.rs/install.sh | sh