Cloning a private Github repo to your EC2 Instance.

Rahul Padalkar
2 min readJan 22, 2021

--

Create a public and private key using ssh-keygen

SSH into your EC2 instance and run the command below. The email address here is your Github account email address.

sudo ssh-keygen -t rsa -C "your-email-address@gmail.com" -b 4096

Keys are generated in /root/.ssh/id_rsa (if you don’t change the default input). The public one is suffixed with .pub

Move both the generated keys to /home/ubuntu/.ssh

Create a Deploy key

Navigate to settings for the repo you want to clone. Click on Deploy Keys tab. You will be greeted with this wonderful screen.

Give your key a cool title and paste the public key you created earlier in the key section. Don’t alter its contents! Hit Add key.

Make sure you are able to connect to Github now by running

ssh -vT git@github.com

In the outbound rules of the EC2 Instance edit the rules to allow connection to Github servers. Allow all traffic to make it simple.

Then run the clone command

git clone git@github.com:OrgName/your-repo.git

That’s it! Thanks for reading!

If you liked what i wrote, you might also like what i tweet. This is my twitter.

Don’t like twitter? Here are some other articles i wrote:

Learnings from a failed product.

Hunting for ideas

--

--

Rahul Padalkar
Rahul Padalkar

No responses yet