zsie5g
Last Updated: May 17, 2017
·
3.933K
· szajbus
Avatar

Use multiple deployment SSH keys with GitHub

GitHub lets you attach a deploy key to one repository only. The problem is when you want to access multiple repositories with tools like capistrano or, as is our case, webistrano which executes git ls-remote locally before ssh'ing to a remote server and doing git clone there.

Here's the trick to make the tool always use the correct key.

Alias github.com host in your ~/.ssh/config and assign a identity key to it.

Host aliased-github
  HostName github.com
  IdentityFile ~/.ssh/my_deploy_key

Now the tool should be configured to deploy from git@aliased-github:username/repository.git

Say Thanks
Respond

2 Responses
Add your response

405
70d9b050bfe39350c234d710fadfcd39

I'm using this SSH feature in my github-keygen tool. https://github.com/dolmen/github-keygen/

over 1 year ago ·
6306
B39f29d7d31b5fbbbaf659a07b1cdb57

wrote a blog article about the same topic 3 days ago (in german): http://www.feldstudie.net/2013/05/06/verwenden-von-mehreren-github-repositories-in-jenkins/ ;)

over 1 year ago ·
Filed Under