加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ruby – Capistrano 3部署无法连接到GitHub – 权限被拒绝(publi

发布时间:2020-12-17 03:49:54 所属栏目:百科 来源:网络整理
导读:我使用Capistrano v3和capistrano / symfony gem设置了以下部署脚本.我正在使用Ubuntu 14.4部署到AWS EC2实例 我正在连接从AWS下载的.pem文件.我在deploy.rb中有以下内容 set :pty,trueset :ssh_options,{ user: 'ubuntu',keys: ['/Users/myuser/Sites/Mypro
我使用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"]
}

部署时

bundle exec cap staging deploy --trace

脚本连接正常,但失败了

INFO [4fd1b02c] Running /usr/bin/env git ls-remote --heads git@github.com:MyName/Myproject.git as ubuntu@ec2-00-000-000-000.eu-west-1.compute.amazonaws.com
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 git@github.com: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 ubuntu@ec2-00-000-000-000.eu-west-1.compute.amazonaws.com: 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

我不知道为什么forward_agent不工作?

我一直在努力遵循这个指南 – https://developer.github.com/guides/using-ssh-agent-forwarding/#testing-ssh-agent-forwarding

但是当我达到这一点

echo "$SSH_AUTH_SOCK"

它打印一个空行.

此外,如果我在服务器上运行它,它说命令未找到

sshd_config

解决方法

仔细检查运行Capistrano的用户是否运行了ssh-agent并且已经添加了相关密钥.

以下是一些很好的指南:

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

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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读