Puedo conectarme con éxito a mi instancia ec2 por ssh:
ssh -i amazon_ec2_123.pem ubuntu@xx.xx.xx.xxx
donde xx.xx.xx.xxx
es mi dirección IP elástica. Luego creé una carpeta llamada my_project.git
y ejecuté git init --bare
en ella.
Entonces hice esto:
cat ~/.ssh/id_dsa.pub | ssh -i amazon_ec2_123.pem ubuntu@xx.xx.xx.xxx "cat >> .ssh/authorized_keys"
En mi máquina local desde el directory fuente de los proyectos, hice esto:
git remote add ec2 ssh://ubuntu@xx.xx.xx.xxx:/home/ubuntu/my_project.git
Sin embargo, cuando traté de presionar al repository, recibí el 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.
¿Qué he hecho mal?
En primer lugar, asegúrese de que puede iniciar session con sus nuevas keys ssh en su instancia EC2.
Una vez que esté seguro de que la connection ssh en sí misma funciona, entonces, en su repository vacío, ejecute
cd git_repo.git mv hooks/post-update.sample hooks/post-update chmod a+x hooks/post-update git update-server-info
Una vez que haya hecho eso, puede agregar el control remoto
git remote add ec2 ubuntu@xx.xx.xx.xxx:/home/ubuntu/my_project.git
Y debería funcionar. Puede leer más sobre la configuration de git en el server en git-scm