如何在 EC2 上推送到 git [英] How to push to git on EC2

查看:20
本文介绍了如何在 EC2 上推送到 git的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试关注 这个 指令.我有一个本地 git 存储库,当我执行 git push 时,我需要将存储库推送到我的 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.

但是,在上面的教程中,当我执行 git push origin master 时,我收到 Permission denied (publickey) 错误,因为我没有指定身份文件.

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

那么,我可以在这里做类似的事情:git -i my_key.pem push origin master 或在 .git/config

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

那么,我该如何设置?

更新: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/*

更新(来自@Jon 的评论):

Update (from @Jon's comment):

如果您的密钥位于奇怪的路径中,只需运行 ssh-add/private/key/path.这对我有用.

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

推荐答案

要将本地 ssh 密钥复制到 amazon 试试这个

To copy your local ssh key to amazon try this

cat ~/.ssh/id_?sa.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

这篇关于如何在 EC2 上推送到 git的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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