部署到EC2实例失败的时候访问GitHub的私人回购协议 [英] Deploying to ec2 instance failing when access GitHub private repo

查看:288
本文介绍了部署到EC2实例失败的时候访问GitHub的私人回购协议的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

设置我的GitHub的帐户大约一年前,并生成新的SSH密钥的时间(以轻松推,并从GitHub上拉的命令行)。前几天我打滑了一个新的EC2实例,并下载了质子交换膜文件,它给了我SSH到它。我可以通过使用质子交换膜文件中的命令行能够轻松地SSH到服务器。

I set up my GitHub account about a year ago, and generated a new SSH key at the time (to easily push and pull from GitHub from Command Line). A few days ago I spun up a new ec2 instance, and downloaded the .pem file it gave me to SSH into it. I am able to easily SSH into the server through the command line using that .pem file.

我使用Capistrano的部署我的Rails应用程序,并运行帽分期部署:检查。在 deploy.rb 文件,我有私人的回购git的URL,并在 staging.rb 文件我已经设置了设置ssh_options 质子交换膜的文件,我从EC2实例下载位置。

I'm using Capistrano to deploy my Rails app, and running the cap staging deploy:check. In the deploy.rb file, I have the private repo git url, and in the staging.rb file I have set the set ssh_options to the location of the .pem file I downloaded from ec2 instance.

当命令开始运行,它连接到服务器的很好,但是当它试图访问混帐回购协议, GIT_ASKPASS = /斌/回声GIT_SSH =的/ tmp /< APP_NAME> / git-ssh.sh的/ usr / bin中/ env的git的LS-远程-h git@github.com:<用户名> /< APP_NAME>的.git 时,出现消息:

When the command starts to run, it is connecting to the server fine, but when it tries to access the git repo, GIT_ASKPASS=/bin/echo GIT_SSH=/tmp/<APP_NAME>/git-ssh.sh /usr/bin/env git ls-remote -h git@github.com:<USERNAME>/<APP_NAME>.git, it fails with the message:

Permission denied (publickey).
fatal: Could not read from remote repository.

一直在研究这个问题在网上,并从我收集它的似乎的,正如我需要相同的SSH为GitHub上和EC2服务器。也许我的信息是不正确......没有成功迄今。

Been researching this issue online, and from what I've gathered it seems like I need the same SSH for both GitHub and the ec2 server. Perhaps my information is incorrect...Have been unsuccessful thus far.

也许需要一些建议纳入这个问题。感谢您的时间。

Would love some advice into this issue. Thank you for your time.

推荐答案

如果该问题是注册的公钥到您的GitHub的帐户,你可以轻松的转换PEM到SSH密钥

If the issue is to register a public key to your GitHub account, you can easily convert a pem to an ssh key:

openssl rsa -in MYFILE.pem -pubout > MYFILE.pub
ssh-keygen -f MYFILE.pub -i -m PKCS8

第一个命令是 OpenSSL:已?如何提取公钥
。 第二个在转换PEM关键支持SSH-RSA格式

The first command is in "openSSL: how to extract public key?".
The second one in "Convert pem key to ssh-rsa format".

由于href="http://stackoverflow.com/users/2456549/justin"> OP贾斯汀确认

As the OP Justin confirms:

我只是用 PuttyGen 转换的质子交换膜到GitHub上想要的格式...这是pfixed与 SSH-RSA

I just used PuttyGen to convert the .pem to the format GitHub wanted...it was prefixed with ssh-rsa.

这篇关于部署到EC2实例失败的时候访问GitHub的私人回购协议的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆