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:
- Generate an SSH key on your computer
- Add your public key to your server or VM
- Test SSH key login
- Create a safer non-root user
- Disable direct root login
- Disable password login for SSH
- 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:
- Private key: stays on your computer and must never be shared
- Public key: copied to the server