Deploying Mulitple Apps to the Same Machine Public Key Restrictions
Reported by Thomas Balthazar | June 10th, 2008 @ 11:53 AM
Hello,
I think it would be great to be able to deploy applications from separated repositories to the same server.
MY SETUP :
- 1 GitHub account with 2 repositories
- 2 Rails apps deployed with Capistrano stored in the 2 repositories
- a Ubuntu 7.1 server (I've patched it and regenerated my SSH keys) on which I deploy those 2 Rails apps from Github
- 1 user named 'deploy' (on the Ubuntu server) that is used to deploy both Rails apps from Github
- 2 public keys on the Ubuntu server (id_rsa.pub and id_rsa_app_2.pub). Those 2 keys are stored in the Github deploy keys, one for each repository
WHAT I TRIED :
- when I do a 'git clone' from the Ubuntu server for the first Rails app/repository, it uses id_rsa.pub and it works fine
- when I do a 'git clone' from the Ubuntu server for the second Rails app/repository, it uses id_rsa.pub and it do not work, since it should use id_rsa_app_2.pub
- if I create a ~/.ssh/config like this one :
Host github.com
IdentityFile /path_to_home/.ssh/id_rsa_app_2.com
and that I try a 'git clone' for the second Rails app/repository, it works fine.
THE FEATURE REQUEST :
- I'd like to be able to perform 'git clone repository_1' and 'git clone repository_2' from the same machine, with the same user, with 2 different SSH keys (since I cannot use the same SSH key for both repositories)
- or it would be nice to use the same deploy key for several repositories
Best,
Thomas.
Comments and changes to this ticket
-
Alexandre Girard June 16th, 2008 @ 04:35 PM
Had the same problem this weekend, tried with differents IdentityFile in ssh config, but didn't work.
Finally created a github user for our public server containing our multiple apps, it's working well, but surely it could be done in a nicer way :)
Would it be possible to define "servers" in github, so it could be used as private/public collaborators without creating a new account?
-

Thomas Balthazar June 17th, 2008 @ 08:53 AM
With the e-mail from Dustin in the Google Group and with this tutorial, I came to this solution that works fine for me :
1/ I create a ~/.ssh/config file like this one :
Host github-project1
HostName github.com
IdentityFile /home/smmweb/.ssh/id_rsa_github_project1
Host github-project2
HostName github.com
IdentityFile /home/smmweb/.ssh/id_rsa_github_project2
2/ Then I can simply do that :
git clone git@github-project1:suitmymind/project1.git
git clone git@github-project2:suitmymind/project2.git
Hope this helps.
-

dustin June 17th, 2008 @ 04:51 PM
There was a subtlety in my suggestion you may have missed. It's possible to DRY that up a bit as you don't need to specify the hostname more than once as long as you have a host pattern. That is, your example could look like this:
In your example, you can add an entry that looks like this (imagine I could format it correctly here):
Host github-*
Hostname github.com
And then you don't need hostname in any of your other entries.
-
Matt Pruitt June 18th, 2008 @ 03:04 AM
- → State changed from new to resolved
- → Milestone cleared.
I'm closing this since it seems to have been solved.
-

Thomas Balthazar June 23rd, 2008 @ 06:39 PM
Unfortunately, the solution I mentioned in my comment from June 17th, 2008 @ 05:53 PM do not work with Capistrano.
I've set this in my deploy.rb file :
set :repository, git@github-project1:suitmymind/project2.git
But when I do a cap deploy, I get this :
Enter passphrase for key '/home/smmweb/.ssh/id_rsa':
Instead of
Enter passphrase for key '/home/smmweb/.ssh/id_rsa_github_project2':
Any idea?
-

Adam Meehan June 26th, 2008 @ 06:47 AM
- → Tag changed from to feature
I am the two account problem, even after applying the solution from the wiki.
When I ssh to the alias for the second account, the ssh log shows it finds the right identity key but github still identifies me as my other account name.
Please Login or create a free account to add a new comment.
You can update this ticket by sending an email to from your email client. (help)
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
