ssh-import-id

An easier way to give someone access

Manual process

You created a new virtual machine on the cloud. Now you are preparing it for the deployment of the new software, but you find yourself struggling with setting up the database connection. You know that John, your colleague, is an expert in it. He needs to log in and for that, you need his SSH key. First, ask him for his public SSH key. Then you add it to the .ssh/authorize_keys, making sure the formatting and file permissions are correct. Finally, it works. It took some back and forth but you get the job done.

Better way

As it’s quite common, if a programmer can simplify it there’s someone who has done it. In the case of the problem described above there’s a small tool called ssh-import-id which helps one to give access to a machine by importing their SSH key. Because the key is public, it can be kept in a public website, like GitHub or Launchpad. The only things you need to know are your teammates usernames. Then it’s just a matter of running:

$ ssh-import-id gh:czyzykowski

The tool has several other options from which ability to remove someone’s key is the most useful.