>_ IzzyLab

Hands-on task

This task is step 5 of the course “SSH: keys and access”

Fix permissions on ~/.ssh

medium~5 min

SSH refuses to work with keys because the directory /root/.ssh and the file /root/.ssh/authorized_keys have permissions that are too open (currently accessible to everyone). Bring them to safe values: the .ssh directory — owner only (700), the authorized_keys file — read/write for owner only (600).

What you'll practise:
  • chmod
  • permissions
  • octal masks
  • ssh
  • key security

Topic breakdown

SSH deliberately ignores keys and authorized_keys if outsiders have access to them — this is protection against theft of private data. Permissions are set with chmod, to which it is convenient to pass a three-digit octal mask (owner / group / others), where each digit is the sum of the read (4), write (2), and execute (1) bits. The .ssh directory should have full access for the owner only, and the authorized_keys file only read and write for the owner; work out the corresponding masks and apply them to both objects. Current permissions can be viewed with stat -c %a or ls -ld.

What's checked

  1. .ssh directory permissions = 700
  2. authorized_keys permissions = 600

What it looks like