不能推到仓库在EC2上 - 无法解析主机名(Can't push to repository

2019-10-19 14:29发布

我可以成功连接到我的EC2实例的SSH:

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

其中xx.xx.xx.xxx是我的弹性IP地址。 然后,我创建了一个文件夹中有名为my_project.gitgit 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

然而,当我试图推到回购,我得到了错误:

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.

我做了什么错?

Answer 1:

首先,确保你能够与你的新的SSH密钥登录到您的EC2实例。

一旦你确认ssh连接本身的工作原理,那么,在你的裸库,运行

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

git update-server-info

一旦你这样做,你可以添加远程

git remote add ec2 ubuntu@xx.xx.xx.xxx:/home/ubuntu/my_project.git

它应该工作。 你可以阅读更多关于设置git的服务器上的git-SCM



文章来源: Can't push to repository on EC2 - Could not resolve hostname