4

I am trying to setup a deployment from my local windows computer through gitlab to my server using capifony.

Usually I would connect by ssh to my server and run the command from the server Now I want to do it from my local computer.

I am already pushing code from my local computer to gitlab with git, i.e. my public key is registered on gitlab.

Here however, it's not working with capifony. What could be the issue ?

The error :

D:\Divers\Programmation\Web\foodmeup.dev>cap development deploy
 ** transaction: start
--> Updating code base with remote_cache strategy
*** [deploy:update_code] rolling back
 ** [deploy:update_code] exception while rolling back: Capistrano::ConnectionError, connection failed for: my_server_ip (ArgumentError: Could not parse PKey: no start line)
connection failed for: my_server_ip (ArgumentError: Could not parse PKey: no start line)

EDIT :

If I follow the instructions given in several post and I put in my deploy.rb the following options

ssh_options[:keys] = %w('~/.ssh/id_rsa')

or

ssh_options[:keys] = %w('~/.ssh/id_rsa.pub')

Then I am asked for a root password and I still get an error (despite the fact I can log in via ssh with putty directly and that running the deployment from my server with another user works without me entering the root password):

D:\Divers\Programmation\Web\foodmeup.dev>cap preprod deploy
 ** transaction: start
--> Updating code base with remote_cache strategy
root@my_server_ip's password:
 ** [my_server_ip  :: err] Error reading response length from authentication socket.
 ** [my_server_ip  :: err] Permission denied (publickey).
 ** [my_server_ip  :: err] fatal: Could not read from remote repository.
 **
 ** Please make sure you have the correct access rights
 ** and the repository exists.
*** [deploy:update_code] rolling back
failed: "sh -c 'if [ -d /home/foodmeup.net/preprod/shared/cached-copy ]; then cd /home/foodmeup.net/preprod/shared/cached-copy && git fetch -q origin && git fetch --tags -q origin && git reset -q --ha
rd f52737bb09edbd968319400e2d535f467c42b04c && git clean -q -d -x -f; else git clone -q -b preprod git@gitlab.com:svassaux/foodmeup.git /home/foodmeup.net/preprod/shared/cached-copy && cd /home/foodme
up.net/preprod/shared/cached-copy && git checkout -q -b deploy f52737bb09edbd968319400e2d535f467c42b04c; fi'" on my_server_ip  
Sébastien
  • 5,263
  • 11
  • 55
  • 116

2 Answers2

0

As mentioned in this issue, one possible reason is:

My problem was that I needed to enclose my ssh key file location in quotes in my config/deploy.rb file, like this:

ssh_options[:keys] = %w('~/.ssh/id_rsa.pub')

instead of:

ssh_options[:keys] = %w(~/.ssh/id_rsa.pub)

Also:

I got this error even when I dont set ssh_options[:keys] in my deploy.rb.

Or:

This problem may be caused by ssh private key with passphrase and no ssh public key.

(also mentioned in issues/101)

Try remove ssh_options[:keys] and invoke the following command:

ssh-keygen -y -f ~/.ssh/id_rsa > ~/.ssh/id_rsa.pub

That leads to:

I launched ProcessMonitor and found ruby process trying to load file ~.ssh\key.pub.pub which gave me an idea that path to the private (not public) key should be in ssh_config['keys'].

So this should work:

ssh_options[:keys] = %w('~/.ssh/id_rsa')

Read also ArgumentError: Could not parse PKey: no start line

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Hi, thanks for this effortof summing all up. I already tried it all and this does not yet solve my issue. I've made an edit. maybe you understand what's happening? – Sébastien Aug 06 '15 at 09:59
  • @Sébastien I see you have two `ssh_options[:keys]`: keep only one, the one with the private key. As I mentioned in my answer. – VonC Aug 06 '15 at 10:21
  • sure, I wrote too fast, I tried both but I get the same error : it asks for a root password and then it fails. I'm not asked for a root password when I deploy from the server itself nor when I connect through to my server from putty... I don't understand what's missing here – Sébastien Aug 06 '15 at 10:33
  • @Sébastien is there a difference in the account used, between your test from putty, which works, and your local session, which would explain that the ssh keys are not found where expected? – VonC Aug 06 '15 at 10:35
  • there is not explanation because I can also use the windows command line to push to git without having to define a location for my keys – Sébastien Aug 13 '15 at 15:37
0

Set ssh_options[:keys] = %w('~/.ssh/id_rsa') , do not set the ssh_options[:keys] = %w('~/.ssh/id_rsa.pub')

J-16 SDiZ
  • 26,473
  • 4
  • 65
  • 84