Multiple ssh keys for git

Ever need to contribute to a repository that isn't hosted at Github? Maybe it's a private Gitlab instance or maybe it's something at Assembla or Bit Bucket.

Whatever the host, if you don't want to re-authenticate to push updates, setting up access to a new remote host includes adding a new ssh key. Each time, I muddle through generating and adding a new .ssh key and telling the new host about it. That second part usually isn't hard but the process of generating a new key always slows me down. As such, I thought I'd put the process here as a note for future me and, who knows, maybe it will save a little time for someone down the line.

Steps for adding an ssh key for a new remote git instance, let's call it coconut:

  • generate a new ssh key:
    ssh-keygen -t rsa -C ""
  • enter a file name whem prompted, include a path like: /Users/you/.ssh/coconut_rsa
  • enter a passphrase
  • update ~/.ssh/config so that ssh know which key to use for the new host, example entry for coconut:
    User git
    IdentityFile /Users/you/.ssh/coconut_rsa
  • copy/paste ssh key to the web: pbcopy < ~/.ssh/
  • paste in the box in whatever website
  • git clone should work over ssh now...something like: