3部署失败连接到GitHub

3部署失败连接到GitHub

本文介绍了Capistrano 3部署失败连接到GitHub - 权限被拒绝(公钥)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下部署脚本,搭配Capistrano v3和capistrano / symfony gem。我正在使用Ubuntu 14.4
部署到AWS EC2实例,我正在使用从AWS下载的.pem文件进行连接。在我的deploy.rb中有以下内容:

  set:pty,true 

set:ssh_options, {
user:'ubuntu',
keys:['/Users/myuser/Sites/Myproject.pem'],
forward_agent:true,
auth_methods:[publickey ]

$ b $ / code>

使用

  bundle exec cap staging deploy --trace 

脚本连接正常,但在此失败

  INFO [4fd1b02c]正在运行/ usr / bin / env git ls-remote --heads git @ github.com:MyName / Myproject.git as [email protected] 
DEBUG [4fd1b02c]命令:(SYMFONY_ENV = prod GIT_ASKPASS = / bin / echo GIT_SSH = / var / www / tmp / myproject / git-ssh.sh / usr / bin / env git ls-remote --heads [email protected]:MyName / Myproject.git)

DEBUG [4fd1b02c]权限被拒绝(公钥)。
DEBUG [4fd1b02c]
DEBUG [4fd1b02c]致命:无法从远程存储库读取。
DEBUG [4fd1b02c]
DEBUG [4fd1b02c]
DEBUG [4fd1b02c]请确保您拥有正确的访问权限
DEBUG [4fd1b02c]
DEBUG [4fd1b02c]和该存储库存在。
DEBUG [4fd1b02c]

中止了帽子!
SSHKit :: Runner :: ExecuteError:以[email protected]执行时出现异常:git退出状态:128
git stdout:权限被拒绝(publickey)。
致命:无法从远程存储库读取。

请确保您拥有正确的访问权限
并存在存储库。
git stderr:没有写入

我不知道为什么forward_agent不工作? / p>

我一直在尝试遵循本指南 -



但是当我到达这个时候

  echo$ SSH_AUTH_SOCK

它打印出一个空行。



在服务器上它说没有找到命令

  sshd_config 


解决方案

仔细检查运行Capistrano的用户是否有 ssh-agent ssh-add 编辑了相关的键。



以下是一些不错的指南:




I have the following deploy script set up with Capistrano v3 and capistrano/symfony gem. I am deploying to an AWS EC2 instance with Ubuntu 14.4I am connecting with a .pem file downloaded from AWS. I have the following in my deploy.rb

set :pty, true

set :ssh_options, {
  user: 'ubuntu',
  keys: ['/Users/myuser/Sites/Myproject.pem'],
  forward_agent: true,
  auth_methods: ["publickey"]
}

when deploying with

bundle exec cap staging deploy --trace

The script connects fine but fails on this

INFO [4fd1b02c] Running /usr/bin/env git ls-remote --heads [email protected]:MyName/Myproject.git as [email protected]
DEBUG [4fd1b02c] Command: ( SYMFONY_ENV=prod GIT_ASKPASS=/bin/echo GIT_SSH=/var/www/tmp/myproject/git-ssh.sh /usr/bin/env git ls-remote --heads [email protected]:MyName/Myproject.git )

DEBUG [4fd1b02c]    Permission denied (publickey).
DEBUG [4fd1b02c]
DEBUG [4fd1b02c]    fatal: Could not read from remote repository.
DEBUG [4fd1b02c]
DEBUG [4fd1b02c]
DEBUG [4fd1b02c]    Please make sure you have the correct access rights
DEBUG [4fd1b02c]
DEBUG [4fd1b02c]    and the repository exists.
DEBUG [4fd1b02c]

cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing as [email protected]: git exit status: 128
git stdout: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
git stderr: Nothing written

I don't know why forward_agent is not working?

I have been trying to follow this guide - https://developer.github.com/guides/using-ssh-agent-forwarding/#testing-ssh-agent-forwarding

but when I get to this

echo "$SSH_AUTH_SOCK"

It prints a blank line.

Also if I run this on the server it says command not found

sshd_config
解决方案

Double-check that the user running Capistrano has ssh-agent running and has ssh-added the relevant key.

Here are some good guides:

https://developer.github.com/guides/using-ssh-agent-forwarding/

http://mah.everybody.org/docs/ssh

这篇关于Capistrano 3部署失败连接到GitHub - 权限被拒绝(公钥)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-12 20:19