Solving SSh communications problems between Amazon EC2 AMIs especially pertaining to GIT (rough technical notes)

Let’s say you have your own GIT repository on one AMI. You want to communicate with it from another AMI. In this example, you want to clone the repository. Also, for this example, you are able to login to both AMIs and have public and private keys for both. The repository is located in /var/git/clientXYZ.git. Your public key file is named myPKfile.pem.

The GIT AMI has an elastic IP address associated with it (e.g. and it is running Ubuntu. If it wasn’t an AMI, you could enter a commend like this:

git clone ssh://username@ to get the information.

This git clone command will not work on the AMI. Instead, you should  create the following file: ~.ssh/config and add the following lines

Host gitserver


User ubuntu

IdentityFile ~/.ssh/myPKfile.pem

 The assumption is the the myPKfile.pem file is already in the .ssh directory. Also, instead of gitserver, you can use any nickname you’d like.

 Once you have this set up, you can then enter this to clone the directory:

git clone ssh://gitserver/var/git/clientXYZ.git

Bonus: you can also ssh gitserver to get to the other AMI

For more good details, see Custom identity file ( with git client / Dev-Articles / DracoBlue.

Comments are closed.