Cap access of a GitHub private repository tip needed ...

587 views
Skip to first unread message

sbtodd

unread,
Jun 10, 2008, 2:13:55 AM6/10/08
to Capistrano
How do I setup Capistrano so that my server can pull my application in
from a private repository
hosted at GitHub?

I can get Cap to pull my application in from a public repository, but
am not sure how to set this
up to pull an application in from a private repository.

Thanks for any tips or help anyone can provide.

Scott Chacon

unread,
Jun 10, 2008, 8:46:21 AM6/10/08
to capis...@googlegroups.com
You need to generate an ssh keypair on each deployment server and add
the public key of each server to the 'deploy keys' section under the
Admin tab of the private repo.

sbtodd

unread,
Jun 10, 2008, 10:26:49 AM6/10/08
to Capistrano
Thanks Scott:
I have a couple of follow up questions:

Presently I use 'deploy' as the username to deploy my Rails app with.

On the server I have the public key of my local development system
stored in:

/home/deploy/.ssh/authorized_keys

1. On the server would I execute this command: ssh-keygen -t rsa?

2. On the server do I store the keys id_rsa & id_rsa.pub in /home/
deploy/.ssh?

3. Should I add the servers id_rsa.pub key to the 'deploy keys'
section of the private repo?

4. How does the server know to use ssh to get the code from the
repository?

[ my cap has this line in it now: set :repository, "git://github.com/
myapp/myapp.git" to access the public repo which works great ]

Thanks for your help,
Todd


On Jun 10, 5:46 am, "Scott Chacon" <scha...@gmail.com> wrote:
> You need to generate an ssh keypair on each deployment server and add
> the public key of each server to the 'deploy keys' section under the
> Admin tab of the private repo.
>

Scott Chacon

unread,
Jun 10, 2008, 5:49:02 PM6/10/08
to capis...@googlegroups.com
> 1. On the server would I execute this command: ssh-keygen -t rsa?
> 2. On the server do I store the keys id_rsa & id_rsa.pub in /home/
> deploy/.ssh?
> 3. Should I add the servers id_rsa.pub key to the 'deploy keys'
> section of the private repo?

Yes to all of these. The first step should do the second automatically.

> 4. How does the server know to use ssh to get the code from the
> repository?
>
> [ my cap has this line in it now: set :repository, "git://github.com/
> myapp/myapp.git" to access the public repo which works great ]

You will need to change your :repository to your clone url, ie:

set :repository, "g...@github.com:myapp/myapp.git"

In git, if there is no protocol specified like that, it assumes ssh.
That line is equivalent to this one:

set :repository, "ssh://g...@github.com:myapp/myapp.git"

Scott

sbtodd

unread,
Jun 10, 2008, 7:06:58 PM6/10/08
to Capistrano
I've done all of this .. put the keys into /home/deploy/.ssh
and changed to the clone URL which got me further ...

Now I get this:

Host key verification failed.

Is there a chance that Capistrano is running as root and trying to
use keys associated with root instead of user 'deploy'?

If so how do I setup the keys for that.

Todd
> set :repository, "ssh://...@github.com:myapp/myapp.git"
>
> Scott

Neil Wilson

unread,
Jun 11, 2008, 6:29:25 AM6/11/08
to Capistrano


On Jun 10, 7:13 am, sbtodd <tdew...@gmail.com> wrote:
> How do I setup Capistrano so that my server can pull my application in
> from a private repository
> hosted at GitHub?

The simplest approach is to change to using one of the copy
strategies.

set :deploy_via, :copy

NeilW

Neil Wilson

unread,
Jun 11, 2008, 6:56:53 AM6/11/08
to Capistrano
You have tried ssh forwarding, haven't you?

set :ssh_options, { :forward_agent => true }

On Jun 10, 7:13 am, sbtodd <tdew...@gmail.com> wrote:

Scott Chacon

unread,
Jun 11, 2008, 8:51:09 AM6/11/08
to capis...@googlegroups.com
I would recommend against this unless you're using it in conjunction with

set :git_shallow_clone, 1

Otherwise it will do a full clone every time you deploy which will get
slower and slower as time goes by. Setting up ssh authentication
should not be hugely difficult - I would recommend logging into your
deploy server as the user set in :

set :user, (user)

and then running 'git clone g...@github.com/(user/project).git' and see
if you get the same error. If so, solve the problem from that side,
if not, then pastie your deploy.rb and I can help further.

Thanks,
Scott

Neil Wilson

unread,
Jun 12, 2008, 4:32:00 AM6/12/08
to Capistrano


On 11 Jun, 13:51, "Scott Chacon" <scha...@gmail.com> wrote:
> I would recommend against this unless you're using it in conjunction with
>
> set :git_shallow_clone, 1
>
> Otherwise it will do a full clone every time you deploy which will get
> slower and slower as time goes by.  Setting up ssh authentication
> should not be hugely difficult - I would recommend logging into your
> deploy server as the user set in :

Ok. Add in

set :copy_cache, true

You shouldn't need extra ssh authentication if you forward the ssh
request.

NeilW

sbtodd

unread,
Jun 12, 2008, 11:22:03 AM6/12/08
to Capistrano
I got this to work.

I was having some problems with keys with multiple accounts at GitHub
that I did not understand,
so I tried Unfuddle

in my deploy.rb file I did this:
set :repository, "git@(acct).unfuddle.com:(acct)/(repo_name).git"
set :scm, :git

on my server (Slicehost) I did this from /home/deploy/.ssh:
ssh-keygen

I then copied the public key over to unfuddle into my personal
settings ..

When I do a cap deploy it looks like it does a git clone .. and it
WORKED!

Thanks for the tips it's helped my understand git, cap and ssh
interaction better.

Todd
Reply all
Reply to author
Forward
0 new messages