Module 2 · Services, SSH and Hardening · Lesson 7 of 10
SSH keys done safely
Create an ed25519 key pair, install only the public key, and prove a second login before changing anything else.
In this lesson · about 20 minutes
- Explain public and private keys in SSH
- Create and install a key, and check permissions
- Change login settings without locking yourself out
Whiteboard · watch and try
Whiteboard: how the server knows it's you
Press Play. The tutor draws the laptop, the server and what travels between them.
Tip: press Pause, then use the pen to work along on the board. Space plays and pauses; Ctrl+Z undoes your last mark.
Try it · watch it happen
How an SSH key logs you in
Press Play to watch the key exchange. Then try the What if buttons.
Your laptop
Server
What if…?
An SSH key pair has two halves:
- The private key (
~/.ssh/id_ed25519) stays on your computer. Anyone who has it can log in as you. Protect it with a passphrase and mode 600. - The public key (
~/.ssh/id_ed25519.pub) can be shared freely. You copy it to the server's~/.ssh/authorized_keys.
When you connect, the server challenges you to prove you hold the private key, without the key ever leaving your machine. Keys can't be guessed like passwords, which is why turning off password logins stops most SSH brute-force attacks.
The golden rule
Validate a second, working login before you disable any existing access method. Keep your current session open, open a new one with the key, and only then change PasswordAuthentication or PermitRootLogin.
Hands-on lab (simulated terminal)
Practice challenge 05: SSH keys
You're on your lab client. The lab server is 10.10.10.5 and your account there is learner.
Step 1 of 4. Type each command and press Enter. Nothing runs on your computer.
1. Generate an ed25519 key pair.
Check your understanding0 of 3 correct
Quiz score: 0 of 3
Noviq Academy is free and for learning. Every terminal here is simulated and every log is synthetic. Practise on a disposable VM with a snapshot, never on a production server. Ubuntu is a trademark of Canonical Ltd.; this course is independent of Canonical.