gpt4 book ai didi

git - 无法推送到 EC2 上的存储库 - 无法解析主机名

转载 作者:行者123 更新时间:2023-12-02 14:38:05 25 4
gpt4 key购买 nike

我可以成功通过 ssh 连接到我的 ec2 实例:

ssh -i amazon_ec2_123.pem ubuntu@xx.xx.xx.xxx

在哪里 xx.xx.xx.xxx是我的弹性 IP 地址。然后我创建了一个 文件夹 那里叫 my_project.git并运行 git init --bare在里面。

然后我这样做了:
cat ~/.ssh/id_dsa.pub | ssh -i amazon_ec2_123.pem ubuntu@xx.xx.xx.xxx "cat >> .ssh/authorized_keys"

在项目源目录的本地计算机上,我这样做了:
git remote add ec2 ssh://ubuntu@xx.xx.xx.xxx:/home/ubuntu/my_project.git

但是,当我尝试推送到 repo 时,我收到了错误:
ssh: Could not resolve hostname xx.xx.xx.xxx:: Name or service not known
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

我做错了什么?

最佳答案

首先,确保您能够使用新的 ssh key 登录到您的 EC2 实例。

一旦您确定 ssh 连接本身可以正常工作,然后,在您的裸存储库中,运行

cd git_repo.git
mv hooks/post-update.sample hooks/post-update
chmod a+x hooks/post-update

git update-server-info

完成后,您可以添加 Remote
git remote add ec2 ubuntu@xx.xx.xx.xxx:/home/ubuntu/my_project.git

它应该工作。您可以在 git-scm 上阅读有关在服务器上设置 git 的更多信息。

关于git - 无法推送到 EC2 上的存储库 - 无法解析主机名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22418746/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com