从windows使用远程主机gitlab部署capifony的权限被拒绝(publickey)



我正在尝试使用capifony从我的本地windows计算机通过gitlab设置部署到我的服务器。

通常我会通过ssh连接到我的服务器,并从服务器运行命令现在我想在我的本地计算机上执行。

我已经用git将代码从我的本地计算机推送到gitlab,即我的公钥已在gitlab上注册。

这里,它不与capifony一起工作。有什么问题吗?

错误:

D:DiversProgrammationWebfoodmeup.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)
编辑:

如果我按照几个帖子给出的说明,我把我的部署。Rb以下选项

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

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

然后我被要求输入根密码,我仍然得到一个错误(尽管事实上我可以直接通过ssh使用putty登录,并且从我的服务器与另一个用户运行部署而无需我输入根密码):

D:DiversProgrammationWebfoodmeup.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  

正如本期所提到的,一个可能的原因是:

我的问题是我需要在我的config/deploy.rb文件中用引号括起我的ssh密钥文件位置,像这样:

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

代替:

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

:

我得到了这个错误,即使我不设置ssh_options[:keys]在我的deploy.rb

或:

这个问题可能是由于ssh私钥有密码而没有ssh公钥引起的。

(也在issue/101中提到)

尝试删除ssh_options[:keys]并调用以下命令:

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

这导致:

我启动了ProcessMonitor,发现ruby进程试图加载文件~.sshkey.pub.pub,这给了我一个想法,私有(非公共)密钥的路径应该在ssh_config['keys']

所以这应该可以工作:

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

请阅读ArgumentError: Could not parse PKey: no start line

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

最新更新