# Can't deploy using Git!

**URL:** <https://www.ruby-forum.com/t/cant-deploy-using-git/169188>\
**Category:** Rails\
**Created:** [May 31, 2009, 3:11am UTC](https://www.ruby-forum.com/t/cant-deploy-using-git/169188 "2009-05-31T03:11:40Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![lpdahito](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/d2c977/32.png) [@lpdahito](https://www.ruby-forum.com/u/lpdahito)\
**Post date:** [May 31, 2009, 3:11am UTC](https://www.ruby-forum.com/t/cant-deploy-using-git/169188/1 "2009-05-31T03:11:40Z")

</div>

Hey guys,

So here’s the deal…  
I’m trying to deploy an app on EC2 using the EC2onRails gem…  
I’m using git as my SCM and capistrano to deploy obviously…

Everytime I try to deploy with this command: cap deploy:cold, I get  
the following error output on my terminal window:

bas1-stlambert20-1178037070:snaproof exponenth$ cap deploy:cold

- executing `deploy:cold’
- executing `deploy:update’  
\*\* transaction: start
- executing `deploy:update\_code’  
updating the cached checkout on all servers  
executing locally: “git ls-remote removed\_email\_address@domain.invalid:lpdahito/  
snaproof.git master”
- executing “if [-d /mnt/app/shared/cached-copy]; then cd /mnt/app/  
shared/cached-copy && git fetch -q origin && git reset -q --hard  
d5b088e509dcc4b476836b5bab0203ce5d4618f9; else git clone -q  
removed\_email\_address@domain.invalid:lpdahito/snaproof.git /mnt/app/shared/cached-copy &&  
cd /mnt/app/shared/cached-copy && git checkout -q -b deploy  
d5b088e509dcc4b476836b5bab0203ce5d4618f9; fi”  
servers: [“[ec2-75-101-235-89.compute-1.amazonaws.com](http://ec2-75-101-235-89.compute-1.amazonaws.com)”]  
[[ec2-75-101-235-89.compute-1.amazonaws.com](http://ec2-75-101-235-89.compute-1.amazonaws.com)] executing command  
\*\* [[ec2-75-101-235-89.compute-1.amazonaws.com](http://ec2-75-101-235-89.compute-1.amazonaws.com) :: out] Permission  
denied (publickey).  
\*\* [[ec2-75-101-235-89.compute-1.amazonaws.com](http://ec2-75-101-235-89.compute-1.amazonaws.com) :: out] fatal: The  
remote end hung up unexpectedly  
\*\* [[ec2-75-101-235-89.compute-1.amazonaws.com](http://ec2-75-101-235-89.compute-1.amazonaws.com) :: out] fetch-pack from  
‘removed\_email\_address@domain.invalid:lpdahito/snaproof.git’ failed.  
command finished  
\*\*\* [deploy:update\_code] rolling back
- executing “rm -rf /mnt/app/releases/20090531003111; true”  
servers: [“[ec2-75-101-235-89.compute-1.amazonaws.com](http://ec2-75-101-235-89.compute-1.amazonaws.com)”]  
[[ec2-75-101-235-89.compute-1.amazonaws.com](http://ec2-75-101-235-89.compute-1.amazonaws.com)] executing command  
command finished  
failed: “sh -c "if [-d /mnt/app/shared/cached-copy]; then cd /mnt/  
app/shared/cached-copy && git fetch -q origin && git reset -q --hard  
d5b088e509dcc4b476836b5bab0203ce5d4618f9; else git clone -q  
removed\_email\_address@domain.invalid:lpdahito/snaproof.git /mnt/app/shared/cached-copy &&  
cd /mnt/app/shared/cached-copy && git checkout -q -b deploy  
d5b088e509dcc4b476836b5bab0203ce5d4618f9; fi"” on  
[ec2-75-101-235-89.compute-1.amazonaws.com](http://ec2-75-101-235-89.compute-1.amazonaws.com)

If you’re looking for my capistrano recipe, here it is:

# This is a sample Capistrano config file for EC2 on Rails.

# It should be edited and customized.

set :application, “snaproof”

set :scm, “git”  
set :repository, “removed\_email\_address@domain.invalid:lpdahito/snaproof.git”  
set :scm\_passphrase, “”  
set :user, “Louis-Pierre D.”  
ssh\_options[:forward\_agent] = true  
set :branch, “master”  
set :deploy\_via, :remote\_cache  
default\_run\_options[:pty] = true

# NOTE: for some reason Capistrano requires you to have both the

public and

# the private key in the same folder, the public key should have the

# extension “.pub”.

ssh\_options[:keys] = [“#{ENV[‘HOME’]}/.ec2/lpdahito.pem”]

# Your EC2 instances. Use the ec2-xxx…amazonaws.com hostname, not

# any other name (in case you have your own DNS alias) or it won’t

# be able to resolve to the internal IP address.

role :web, “[ec2-75-101-235-89.compute-1.amazonaws.com](http://ec2-75-101-235-89.compute-1.amazonaws.com)”  
role :app, “[ec2-75-101-235-89.compute-1.amazonaws.com](http://ec2-75-101-235-89.compute-1.amazonaws.com)”  
role :memcache, “[ec2-75-101-235-89.compute-1.amazonaws.com](http://ec2-75-101-235-89.compute-1.amazonaws.com)”  
role :db, “[ec2-75-101-235-89.compute-1.amazonaws.com](http://ec2-75-101-235-89.compute-1.amazonaws.com)”, :primary  
=\> true

# role :db, "ec2-56-xx-xx-

[xx.z-1.compute-1.amazonaws.com](http://xx.z-1.compute-1.amazonaws.com)", :primary =\> true, :ebs\_vol\_id =\>  
‘vol-12345abc’

# optinally, you can specify Amazon’s EBS volume ID if the database is

persisted

# via Amazon’s EBS. See the main README for more information.

# Whatever you set here will be taken set as the default RAILS\_ENV

value

# on the server. Your app and your hourly/daily/weekly/monthly scripts

# will run with RAILS\_ENV set to this value.

set :rails\_env, “production”

# EC2 on Rails config.

# NOTE: Some of these should be omitted if not needed.

set :ec2onrails\_config, {

# S3 bucket and “subdir” used by the ec2onrails:db:restore task

# NOTE: this only applies if you are not using EBS

:restore\_from\_bucket =\> “your-bucket”,  
:restore\_from\_bucket\_subdir =\> “database”,

# S3 bucket and “subdir” used by the ec2onrails:db:archive task

# This does not affect the automatic backup of your MySQL db to S3,

it’s

# just for manually archiving a db snapshot to a different bucket

if

# desired.

# NOTE: this only applies if you are not using EBS

:archive\_to\_bucket =\> “your-other-bucket”,  
:archive\_to\_bucket\_subdir =\> “db-archive/#{Time.new.strftime(‘%Y-%m-  
%d–%H-%M-%S’)}”,

# Set a root password for MySQL. Run "cap

ec2onrails:db:set\_root\_password"

# to enable this. This is optional, and after doing this the

# ec2onrails:db:drop task won’t work, but be aware that MySQL

accepts

# connections on the public network interface (you should block the

MySQL

# port with the firewall anyway).

# If you don’t care about setting the mysql root password then

remove this.

# Any extra Ubuntu packages to install if desired

# If you don’t want to install extra packages then remove this.

:packages =\> [“logwatch”, “imagemagick”],

# Any extra RubyGems to install if desired: can be “gemname” or if

a

# particular version is desired “gemname -v 1.0.1”

# If you don’t want to install extra rubygems then remove this

# NOTE: if you are using rails 2.1, ec2onrails calls 'sudo rake

gem:install’,

# which will install gems defined in your rails configuration

:rubygems =\> [“rmagick”, “rfacebook -v 0.9.7”],

# extra security measures are taken if this is true, BUT it makes

initial

# experimentation and setup a bit tricky. For example, if you do

not

# have your ssh keys setup correctly, you will be locked out of your

# server after 3 attempts for upto 3 months.

:harden\_server =\> false,

#if you want to harden the server, or setup email signing, you will  
need to set the domain  
#if you use Capistrano’s multistage extension (recommended!), you  
can add a line like this to your  
#environment specific file:

# ec2onrails\_config[:service\_domain] = ‘[staging.mydomain.com](http://staging.mydomain.com)’

:service\_domain =\> nil,

# Set the server timezone. run "cap -e

ec2onrails:server:set\_timezone" for

# details

:timezone =\> “UTC”,

# Files to deploy to the server (they’ll be owned by root). It’s

intended

# mainly for customized config files for new packages installed via

the

# ec2onrails:server:install\_packages task. Subdirectories and files

inside

# here will be placed in the same structure relative to the root of

the

# server’s filesystem.

# If you don’t need to deploy customized config files to the server

then

# remove this.

:server\_config\_files\_root =\> “…/server\_configs”,

# If config files are deployed, some services might need to be

restarted.

# If you don’t need to deploy customized config files to the server

then

# remove this.

:services\_to\_restart =\> %w(postfix sysklogd),

# Set an email address to forward admin mail messages to. If you

don’t

# want to receive mail from the server (e.g. monit alert messages)

then

# remove this.

:mail\_forward\_address =\> “removed\_email\_address@domain.invalid”,

# Set this if you want SSL to be enabled on the web server. The SSL

cert

# and key files need to exist on the server, The cert file should be

in

# /etc/ssl/certs/default.pem and the key file should be in

# /etc/ssl/private/default.key (see :server\_config\_files\_root).

:enable\_ssl =\> true  
}

I just don’t know what I’m doing wrong !!! Wasn’t I be supposed to  
deploy my app in 5 minutes lol…

Please someone I need help !

Thx

Louis-Pierre

---

<div class="post-metadata">

**Author:** ![lpdahito](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/d2c977/32.png) [@lpdahito](https://www.ruby-forum.com/u/lpdahito)\
**Post date:** [May 31, 2009, 3:39am UTC](https://www.ruby-forum.com/t/cant-deploy-using-git/169188/2 "2009-05-31T03:39:22Z")

</div>

On May 31, 2:10 am, lpdahito [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> - executing “if [-d /mnt/app/shared/cached-copy]; then cd /mnt/app/  
> shared/cached-copy && git fetch -q origin && git reset -q --hard  
> d5b088e509dcc4b476836b5bab0203ce5d4618f9; else git clone -q  
> removed\_email\_address@domain.invalid:lpdahito/snaproof.git /mnt/app/shared/cached-copy &&  
> cd /mnt/app/shared/cached-copy && git checkout -q -b deploy  
> d5b088e509dcc4b476836b5bab0203ce5d4618f9; fi”  
> servers: [“[ec2-75-101-235-89.compute-1.amazonaws.com](http://ec2-75-101-235-89.compute-1.amazonaws.com)”]  
> [[ec2-75-101-235-89.compute-1.amazonaws.com](http://ec2-75-101-235-89.compute-1.amazonaws.com)] executing command  
> \*\* [[ec2-75-101-235-89.compute-1.amazonaws.com](http://ec2-75-101-235-89.compute-1.amazonaws.com) :: out] Permission  
> denied (publickey).

This is saying that your ec2 instance didn’t have the right  
credentials to talk to your github account - either it is using a  
public key that you haven’t added to the account (either straight to  
the account or as a deploy key for the repository in question) or it  
doesn’t have a key at all.

Fred

---

<div class="post-metadata">

**Author:** ![lpdahito](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/d2c977/32.png) [@lpdahito](https://www.ruby-forum.com/u/lpdahito)\
**Post date:** [May 31, 2009, 4:14am UTC](https://www.ruby-forum.com/t/cant-deploy-using-git/169188/3 "2009-05-31T04:14:13Z")

</div>

I’ve generated a keypair from my instance and copied the public one to  
github…  
Like you’ve said, I’ve put it in the account… didnt work…  
I’ve tried as a deploy key also… without success either…

That’s mainly the reason why i’m on this forum right now…

thx for your help…  
Still need help though

LP

On May 30, 9:38 pm, Frederick C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![lpdahito](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/d2c977/32.png) [@lpdahito](https://www.ruby-forum.com/u/lpdahito)\
**Post date:** [May 31, 2009, 4:30am UTC](https://www.ruby-forum.com/t/cant-deploy-using-git/169188/4 "2009-05-31T04:30:04Z")

</div>

On May 31, 3:13 am, lpdahito [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I’ve generated a keypair from my instance and copied the public one to  
> github…  
> Like you’ve said, I’ve put it in the account… didnt work…  
> I’ve tried as a deploy key also… without success either…

And you’ve copied the keys to your ec2 instances (probably also  
sensible to setup your ssh config there to tell it to use that key  
when talking to github) ?  
Have you tried sshing into one of your instances and doing a git clone  
from the command line (ie see if it’s just capistrano screwing  
around) ?

Fred

---

<div class="post-metadata">

**Author:** ![lpdahito](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/d2c977/32.png) [@lpdahito](https://www.ruby-forum.com/u/lpdahito)\
**Post date:** [May 31, 2009, 6:27am UTC](https://www.ruby-forum.com/t/cant-deploy-using-git/169188/5 "2009-05-31T06:27:21Z")

</div>

I’ve tried sshing into the instance and i successfully cloned the  
repo…

If the problem is Capistrano… what’s wrong in the code above… it  
seems perfect to me…

thx again

LP

On May 30, 10:29 pm, Frederick C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![lpdahito](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/d2c977/32.png) [@lpdahito](https://www.ruby-forum.com/u/lpdahito)\
**Post date:** [May 31, 2009, 2:28pm UTC](https://www.ruby-forum.com/t/cant-deploy-using-git/169188/6 "2009-05-31T14:28:32Z")

</div>

I think what you want to do is make sure that you can ssh (or git  
clone) from the machine (in this EC2 machine) to git so that github’s  
public key certificate can be added to the known\_hosts file of your  
“deploy” user (the user that capistrano runs as on EC2 machine) so  
that EC2 machine to Github connection is a trusted connection. I had  
no ends of trouble because of this since I forgot to do this.

---

<div class="post-metadata">

**Author:** ![lpdahito](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/d2c977/32.png) [@lpdahito](https://www.ruby-forum.com/u/lpdahito)\
**Post date:** [June 1, 2009, 1:25pm UTC](https://www.ruby-forum.com/t/cant-deploy-using-git/169188/7 "2009-06-01T13:25:35Z")

</div>

All that has been done…  
I’ve no problem at all sshing into my instance and cloning the repo  
from there…  
It seems that the problem would be with capistrano…
