samedi 26 avril 2014

git - ne peut pas pousser au référentiel sur EC2 - n'a pas pu résoudre hostname - Stack Overflow


I can successfully connect to my ec2 instance by ssh:


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

where xx.xx.xx.xxx is my elastic ip address. Then I created a folder there called my_project.git and ran git init --bare in it.


Then I did this:


cat ~/.ssh/id_dsa.pub | ssh -i amazon_ec2_123.pem ubuntu@xx.xx.xx.xxx "cat >> .ssh/authorized_keys"

At my local machine from the projects' source directory I did this:


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

However, when I tried to push to the repo, I got the error:


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.

What have I done wrong?




First of all, make sure that you are able to login with your new ssh keys into your EC2 instance.


Once you are sure that the ssh connection itself works, then, in your bare repository, run


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

git update-server-info

Once you have done that, you can add the remote


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

And it should work. You can read more about setting up git on the server on git-scm



I can successfully connect to my ec2 instance by ssh:


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

where xx.xx.xx.xxx is my elastic ip address. Then I created a folder there called my_project.git and ran git init --bare in it.


Then I did this:


cat ~/.ssh/id_dsa.pub | ssh -i amazon_ec2_123.pem ubuntu@xx.xx.xx.xxx "cat >> .ssh/authorized_keys"

At my local machine from the projects' source directory I did this:


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

However, when I tried to push to the repo, I got the error:


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.

What have I done wrong?



First of all, make sure that you are able to login with your new ssh keys into your EC2 instance.


Once you are sure that the ssh connection itself works, then, in your bare repository, run


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

git update-server-info

Once you have done that, you can add the remote


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

And it should work. You can read more about setting up git on the server on git-scm


0 commentaires:

Enregistrer un commentaire