Authenticated as: Anonymous (Change Credentials / Create Account)

Howto: Single Purpose SSH Keys

You have a job (such as a backup, or perhaps you're paranoid about SNMP and wrote your own status checker using ssh) that a remote machine needs to run automatically, but you don't fully trust the machine to be secure (or the operator to be honest). The idea of giving a complete shell - especially one with sudo access to do your backup job - and key over to an untrusted entity just doesn't leave you sleeping well at night.

Single purpose SSH keys are designed for exactly this behaviour. I'll bet you weren't aware you can modify a normal SSH key to enforce a rudimentary access policy on the shell using nothing more than ssh did you? It's a piece of cake:

Using your keys with (Open)SSH

The ssh client will allow you to specify a key to use when you use the -i parameter:

ssh -i ~/.ssh/uptime somehost

I personally don't recommend adding it to your id_dsa file unless this account is strictly an account for that one purpose.

Using with putty

Ideas for sort-of-secure backups

If it were me setting up an off-site backup over SSH, I would have the majority of the backup logic on the host, having it say, making an encrypted backup of all the files and then creating an ISO-9660 image out of the whole mess, and piping that over the SSH.

Since you'd be encrypting the data going over the wire anyway, you might want to select a more light-weight crypto mechanism to save wear-and-tear on the machine (but you could "nice" the backup process to make it run in idle-time). If you keep the keys for whatever encryption mechanism you use elsewhere (not on either the backup machine or the host), then the backup machine if compromised will never see any actual data.

There are probably holes in this theory, I'm sure. I just thought I'd throw it in as food for thought at the tail end of this article.

Update: September 2007

"betabug" writes to bring to our attention that ssh server administrators have even more control over single use access, via the ForceCommand directive. Check out the manual for more information.