>_ IzzyLab

Hands-on task

This task is step 4 of the course “New server: setup from scratch”

SSH keys done right

medium~15 min

User alice needs SSH key access. Generate her an ed25519 pair in /home/alice/.ssh/id_ed25519 (without a passphrase), add the public key to her authorized_keys, and set the permissions that SSH actually accepts: 700 on .ssh, 600 on the files, everything owned by alice.

What you'll practise:
  • ssh-keygen
  • ed25519
  • authorized_keys
  • ssh permissions
  • chmod/chown

Topic breakdown

SSH key authentication is built on an asymmetric pair: the private key stays with the user as a secret, while the public one is placed on the server in ~/.ssh/authorized_keys. The key generator can create pairs of various types (ed25519 being a modern, compact algorithm) and via flags accepts the type, an empty or specified passphrase, and the save path. A separate and mandatory layer is permissions: sshd deliberately ignores keys if the .ssh directory or files are accessible more widely than needed, so the modes (directory — owner only, key files — read/write for the owner) and the correct owner are set via chmod and chown and are part of the working configuration, not a trifle.

What's checked

  1. passphrase-less ed25519 key created
  2. this pair's public key is in authorized_keys
  3. permissions 700 on .ssh and 600 on the keys
  4. files owned by alice

What it looks like