The many uses of authorized_keys

The many uses of authorized_keys

Most of us meet ~/.ssh/authorized_keys on the day we stop typing passwords into SSH. You generate a key pair, run ssh-copy-id, and from then on your laptop is trusted by the server. For many people that is where the story ends: the file is just a list of public keys that are allowed to log in.

In fact each line of authorized_keys can carry a set of options that change what that particular key is allowed to do. A key can be limited to a single command, to connections from one address, to opening one tunnel, or to working only until a certain date. Used well, this lets you hand out keys for backups, deployments and monitoring without handing out a shell.

This article walks through those options, with practical examples. It assumes OpenSSH, which is what nearly every Linux distribution ships. Some options are fairly recent, so the OpenSSH version that introduced them is noted where it matters; run ssh -V to check yours.

Continue reading →