I have a strange problem with cloning a git repository from an amazon ec2 server. It works without any problems on one of my computers running ubuntu 12.04, while on another one using 12.10 it gives me an error:
ssh: Could not resolve hostname ec2server: Name or service not known
fatal: The remote end hung up unexpectedly
It’s like it is not recognizing my config file. I use the following git command to clone :
sudo git clone ec2server:/var/www/project.git
or
sudo git clone ec2xxx.compute-1.amazonaws.com:/var/www/project.git
The two config files are identical on both computers, inside the ~./ssh with the following content:
Host ec2server
Hostname ec2XXX.compute-1.amazonaws.com
User ubuntu
IdentityFile ~/.ssh/mykey.pem
If I substitute the ec2server with the actual address I get the following error:
Cloning into 'project'...
Permission denied (publickey).
fatal: The remote end hung up unexpectedly
Thanks in advance.
Recently I had to re-install the system which held the working configuration and I have not managed to replicate it, so it’s not about the linux version (very likely). What I managed to do, is that I managed to use the mentioned original script to clone the repository into my home directory. Here it picked up the name correctly, but if I navigated into /var/www, what I was doing before, it just gave me the same error: could ec2server not found … . So I figure the problem has to do something with the permissions + commands combination. If anyone can figure it out how to make it work, I will mark he’s response as a correct answer, until then I am marking mine as the correct one, since this is the closest to the correct.
UPDATE
I figured it out what was the problem: I had to change the permission on /var/www folder in order to be able to clone into that directory. Now it’s 777 ( used only for dev on a local machine).