设置的Git在EC2上从GitHub库拉 [英] Setting up Git on EC2 to pull from GitHub repo

查看:158
本文介绍了设置的Git在EC2上从GitHub库拉的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是一种新的既EC2​​和Git,我也刚刚成立EC2我的第一个实例,用干净的亚马逊的Linux AMI。我还安装了MySQL,Apache和PHP和打开一些端口,使其作为一个正常的Web服务器的工作,响应弹性IP为好。

I'm kind of new to both EC2 and Git, and I have just set up my first instance of EC2, using a clean Amazon Linux AMI. I also installed MySQL, Apache and PHP and opened some ports to make it work as a normal web server, responding to an elastic IP as well.

现在,我的code是在GitHub上的私人回购协议,我想这样做混帐拉或类似的东西进行简单的部署。 Git是也安装在服务器上了。我知道我可以设置我的git仓库用我个人的SSH密钥的服务器上,但它似乎很奇怪。我想另一种解决方案是创建一个新的GitHub的用户,并用它在服务器上,但它看起来不正确或者。

Now, my code is on a private repo on GitHub, and I would like to perform simple deployments by doing git pull or something like that. Git is also installed on the server already. I know I could set up my git repo on the server using my personal ssh key, but it seems odd. I guess another solution would be to create a new GitHub user and use it on the server, but it doesn't seem right either.

在一个优雅的,安全的方式我如何做到这一点?

How do I achieve this in an elegant, safe way?

推荐答案

要避免保持一个SSH私钥对你的EC2实例,人们经常使用,涉及推到远程服务器,以便部署的工作流。从本质上讲,你设置了一个光秃秃的git仓库有一个 pre-收到挂钩,部署到其他目录。有做这在本教程一个简单的例子。然后,你只需要在您的SSH的公开的键的〜/ .ssh / authorized_keys中在服务器上。然而,与此工作流程,你不能直接从您的GitHub库部署 - 你需要在当地拉,然后推到EC2机

To avoid having to keep an SSH private key on your EC2 instance, people often use a workflow that involves pushing to that remote server in order to deploy. Essentially, you set up a bare git repository there with a pre-receive hook that deploys to another directory. There is a simple example of doing this in this tutorial. Then you only need to have your SSH public key in ~/.ssh/authorized_keys on the server. However, with this workflow, you couldn't deploy directly from your GitHub repository - you would need to pull it locally and then push to the EC2 machine.

另一种方法是使用GitHub的部署键机制。这就需要建立一个新的SSH密钥对你的EC2实例,并添加公钥作为部署钥匙插入您在GitHub上的私人信息库。然后你就可以直接从您的私人GitHub的版本库到你的EC2实例。

An alternative is to use GitHub's deploy keys mechanism. This would involve creating a new SSH key-pair on your EC2 instance, and adding the public key as a deploy key into your private repository on GitHub. Then you can pull directly from your private GitHub repository to your EC2 instance.

这篇关于设置的Git在EC2上从GitHub库拉的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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