如何推与git的EC2git

2023-09-11 08:04:47 作者:久经风霜

我试图按照this指令。我有一个本地的git仓库,当我做一个混帐推,我需要回购推送到我的EC2实例。

I am trying to follow this instruction. I have a local git repo and when I do a git push, I need the repo to be pushed to my EC2 instance.

不过,在上面的教程,当我做了混帐推起源主,我得到权限被拒绝(公钥)错误,因为我没有指定的标识文件。

But, in the above tutorial, when I do a git push origin master, I get Permission denied (publickey) error because I did not specify the identity file.

说,我登录到EC2这样的:的ssh -i my_key.pem username@11.111.11.11

Say, I login to EC2 like this: ssh -i my_key.pem username@11.111.11.11

所以,我可以做类似这里的东西:混帐-i my_key.pem推动产地主或设置的标识文件 git的/配置

So, can I do something similar here to: git -i my_key.pem push origin master or set the identity file in .git/config

那么,我该怎么设置?

更新:混帐配置-l

user.name=my name
user.email=my_email_addreess@gmail.com
github.user=userid
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
core.ignorecase=true
remote.origin.url=ec2_id@my_e2_ip_address:express_app
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*

更新(来自@乔恩的comment):

Update (from @Jon's comment):

如果你有你的钥匙在一个奇怪的路径只需运行的ssh-添加/私营/按键/路径。这为我工作。

If you have your key in an odd path just run ssh-add /private/key/path. This worked for me.

推荐答案

要在本地SSH密钥复制到亚马逊尝试这种

To copy your local ssh key to amazon try this

cat ~/.ssh/id_dsa.pub | ssh -i amazon-generated-key.pem ec2-user@amazon-instance-public-dns "cat >> .ssh/authorized_keys"

替换过程中的关键和亚马逊EC2公共DNS的名称。

replacing the names of the key and amazon ec2 public dns, of course.

您将能够设置遥控器上亚马逊

you will then be able to setup your remote on amazon