Ssh – Multiple SSH keys per user on the server

authenticationsshssh-keys

Say I run a server which accepts SSH connections, and being a wise person, I use SSH keys instead of passwords to connect to it. There is one user, webmaster, which has access to and controls the website-related directories and programs. Whenever I connect to the server, I log in as webmaster.

This is working great, until one day I hire a third party company to work on the website for a week, and to make things go smoothly, I want them to log in as webmaster when they do their work. When the week is over and the job is done, I want to revoke access to the server with their key.

How would I go about doing this, having multiple keys for the same user on the server, that can be edited or removed independently?

Best Answer

This functionality is already supported. When you add their public key to ~webmaster/.ssh/authorized_keys just make sure you remember which key is theirs. When they're done, remove the line for their public key in authorized_keys. You can always change the last little bit of a public key that looks like an email address. Please remember that the permissions for your authorized_keys file is important and that it must be the user webmaster and the permissions 0600 (rw-------).