Pcornel
Linux · SSH

authorized_keys

Cheat sheet · https://pcornel.dk/topic.php?topic=2803

Back to the Topic

Answer

~/.ssh/authorized_keys lists the public keys allowed to log in as that user, one per line, optionally with options such as from=, command= and restrict.

Remember

One key per line, no line breaks. Remove a key to revoke access. Use from="<net>" to limit where a key may be used. Ownership and permissions must be strict or sshd ignores the file.

First checks

  • ssh -v user@host — client-side connection and authentication steps
  • journalctl -u ssh -u sshd -e — server log
  • sshd -T — effective server settings
  • ss -ltnp | grep :22 — sshd listening

Verify in this order

key added on one line → strict permissions → sshd reads the file → key and options matched

Where it usually breaks

First mismatch in link/interface → address/namespace → route/neighbor → firewall/policy → socket/daemon → DNS/TLS/SSH/application peer path; preserve identity/native diagnostic/pre-state before mutation.

Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=2803

Confirmation

Confirm action

Continue?