Note: This guide was adapted from this Notion page, and I added in more commands that were useful for me.

Beginner Guide: Secure SSH Access to a Linux VM

What this guide helps you do

This guide shows you how to:

  1. Generate an SSH key on your computer
  2. Add your public key to your server or VM
  3. Test SSH key login
  4. Create a safer non-root user
  5. Disable direct root login
  6. Disable password login for SSH
  7. Restart SSH safely without locking yourself out

This is the standard secure setup for most Linux servers.


Before you start

What is SSH?

SSH lets you connect to a remote server or VM from your computer.

What is an SSH key?

An SSH key comes in two parts: