Search code examples
symfonysshcapistranocapifony

Authentication failed with capifony


I'm trying to do a Symfony 2 project deployment web app based on capifony and Symfony2.

It uses Process to trigger my "cap deploy" task and display my output in a web browser.

When in a shell, if I run my "cap deploy" as user www-data (the same as used by Process) , my deployement works fine so there's nothing wrong either with my deploy task nor with my authentication keys. Though, when I call my task from my web app, capifony tells me it can't authenticate on the remote server.

triggering start callbacks for `deploy'

* executing `deploy:setdomain'
* executing `deploy'
* executing `deploy:update'
** transaction: start
* executing `deploy:update_code'

triggering before callbacks for `deploy:update_code'

[32m--> Updating code base with checkout strategy[0m

executing locally: "git ls-remote [ myrepo ]"

command finished in 2068ms

* executing "git clone -q -o [ remote server ] [ my repo ] 
/var/www/spinfony/releases/20121211100449 && cd /var/www/spinfony/releases/20121211100449 && git checkout -q -b deploy be53233e51a4c542c3bc8603b424e57f988898a4 && (echo be53233e51a4c542c3bc8603b424e57f988898a4 > /var/www/spinfony/releases/20121211100449/REVISION)"

servers: ["[ remote server ]"]
Password: stty: standard input: Invalid argument
stty: standard input: Invalid argument
stty: standard input: Invalid argument

*** [deploy:update_code] rolling back

* executing "rm -rf /var/www/spinfony/releases/20121211100449; true"

servers: ["[ remote server ]"]
** [deploy:update_code] exception while rolling back: Capistrano::ConnectionError, connection failed for: [ remote server ] (Net::SSH::AuthenticationFailed: [ user ])
connection failed for: [ remote server ] (Net::SSH::AuthenticationFailed: [ user ])

I'm trying to figure out why capifony seems to expect a password I can't provide since i'm not running it from a shell, whereas when I do run it from a shell, it works fine without asking me anything.

Once again, the same file is called from the same user.


Solution

  • This is a known "bug"

    You need to tell capistrano wich key to use

    Try adding this to your deploy.rb :

    ssh_options[:keys] = %w(/what/ever/.ssh/id_rsa)
    

    Source : http://adam.goucher.ca/?p=1253