SSH auth for multiple GitHub accounts on OSX > stdout.in Ievgen Kuzminov IT blog

SSH auth for multiple GitHub accounts on OSX

Jun 29, 2016, 9:37:56 AM

When you use more than one SSH key to access GitHub you can use primary account by default and additional, with such a config (assume your second SSH key file is ~/.ssh/id_rsa_pewpew)

Host github-pewpew
  HostName github.com
  IdentityFile ~/.ssh/id_rsa_pewpew

With Linux having ssh key in .ssh folder and configuring ~/.ssh/configis enough. But on MacOS I get an error during Git clone (and Capistrano deploy) like this:

git clone git@github-pewpew:.../...git
Cloning into 'MyRepo'...
ERROR: Repository not found.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights and the repository exists.

a bit confusing, but an error is not with Repo by itself (if you are completely sure that you are the repo owner or have write-rights).

Solution

On MacOS X I need to additional keys manually by

$ ssh-add ~/.ssh/id_rsa_pewpew

and you can check what key are in use right now

$ ssh-add -l

Note

On MacOS X you will need to add key after every system restart. It looks like we need to use OSX Keychain to reload them authomatically via

$ ssh-add -K [path/to/private SSH key]

comments powered by Disqus
Ievgen
Kuzminov "iJackUA"
Web Team Lead
at MobiDev (Kharkiv, Ukraine)
Code in Ruby and Elixir, but still love PHP. Explore ES6 and Vue.js. Explore databases, use Ubuntu and MacOS, think about IT people and management

Notes


Animista - is a place where you can play with a collection of ready to use CSS animations, tweak them and download only those you will actually use.



Staticman - handles user-generated content for you and transforms it into data files that sit in your GitHub repository, along with the rest of your content.