Home > Mobile >  Clone (private) Github repo to EC2
Clone (private) Github repo to EC2

Time:07-28

I'm trying to clone a private Github repo to a new Amazon EC2 (Ubuntu) instance.

The EC2 Instance fails to git clone <PATH> due to

[email protected]: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

Here's my steps:

  1. Run ssh-keygen on local machine
  2. Add the newly generated public key (~/.ssh/id_rsa.pub) into GitHub 'SSH Keys' section
  3. Also import that public key into the EC2 'Key Pairs' dashboard
  4. Make the instance ensuring that new Key Pair is used during launch
  5. log into EC2 instance, update yum and yum install git etc
  6. Try git clone <PATH> but get permission error. Works fine on local machine...

I'm not fully understanding how EC2 is using my Key Pair... why doesn't GitHub recognize the EC2 instance?

CodePudding user response:

"Also import that public key into the EC2 'Key Pairs' dashboard"

That only allows you to use that key pair for SSH into EC2 instances. And only instances that you create after you add that key pair to AWS. That key pair management dashboard has nothing to do with the git command you are running on the EC2 server.

You need to copy your local ~/.ssh/id_rsa private key file to that same location on the EC2 server.

  • Related