Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

SSH

If you’re running your server on a mini PC, setting up SSH is optional but super convenient. It lets you access the machine from any other device on your local network without needing to sit in front of it. On the other hand, if you’re using a VM, SSH is pretty much the default way to connect, so you’ll likely already have it in place.

Here’s how I set it up on my machine following a guide 1 from DigitalOcean.

  1. Update package repositories
sudo apt update
  1. Install OpenSSH server
sudo apt-get install openssh-server
  1. Start the SSH server (if not already started)
sudo systemctl start ssh
  1. Verify that the computer is listening on the standard SSH ports (22)
sudo ss -ltup | grep 22
  1. Allow connections to the SSH TCP ports if using UFW
sudo ufw allow OpenSSH
# or
sudo ufw allow ssh
  1. Connect to the SSH server
ssh <user>@<ip>
  1. Create a private / public key pair on the client (passphrase is optional but recommended)
ssh-keygen -t ed25519
  1. Secure copy the public key to the server
scp <key>.pub <user>@<ip>:~/.ssh/<key>.pub
  1. Add the public key to the authorized_keys file of the server

  2. You can also do steps 9 & 10 with one command

ssh-copy-id -t <path-to-key> <user>@<ip>

  1. SSH Essentials: Working with SSH Servers, Clients, and Keys