.ssh with amazon ec2 and git

I have a weird issue with cloning a git repository from amazon ec2 server. It works without problems on one of my computers running ubuntu 12.04, and on the other 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 

I like that it does not recognize my configuration 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 configuration files are identical on both computers inside ~. / Ssh with the following contents:

 Host ec2server Hostname ec2XXX.compute-1.amazonaws.com User ubuntu IdentityFile ~/.ssh/mykey.pem 

If I replace 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.

+8
git amazon-ec2 config public-key
source share
2 answers

I recently had to reinstall the system in which the working configuration was stored, and I could not replicate it, so this is not about the Linux version (very likely). What I was able to do was that I was able to use the mentioned original script to clone the repository into my home directory. Here he chose the right name, but if I went to / var / www, which I did before, he just gave me the same error: ec2server could not .... Therefore, I believe that the problem should do something with the combination permissions + teams. If anyone can figure out how to make it work, I will mark his answer as the correct answer, until I mark it as the correct one, as this is closest to the correct one.

UPDATE

I realized what the problem was: I had to change the permission to / var / www in order to be able to clone into this directory. Now it is 777 (used only for dev on the local machine).

+5
source share

This is usually a resolution issue.
chmod in the parent directories of your configuration file may be different between your two computers.
(and I'm not only talking about the closest parent .ssh , but also all parent directories)

See β€œ Git Checking SSH, ” but also be aware that if any of the parent directories are writable by group or world, ssh will not work.


Please note that your second command is incorrect and should be:

 git clone ubuntu@ec2xxx.compute-1.amazonaws.com/var/www/project.git 

no ' : ' (a ' : ' means using a config file with scp syntax)

it can only work if you have ~/.ssh/id_rsa and ~/.ssh/id_rsa.pub .
If you have mykey.pem, you need a config file for ssh to find out where your public and private keys are, which means this can only work:

 git clone ec2server:/var/www/project.git 

Another tip (after this thread and this forum ) is to check if there is any DNS / DHCP problem (a bit like working with git for dynamic DNS ).

 Host ec2server Hostname 1xx.xxx.xxx.xxx # ip address of ec2XXX.compute-1.amazonaws.com User ubuntu IdentityFile ~/.ssh/mykey.pem 
+5
source share

All Articles