Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Can't find /root/.ssh/id_rsa after generating key pair from amazon EC2 instance

I am trying to clone my private github repository on Amazon EC2 and for that I have generated key pair using this command in EC2 instance’s console:

sudo ssh-keygen -t rsa -C "email_id@gmail.com" -b 4096

After this console is showing something like this
enter image description here

I am new to AWS EC2 so I don’t know where to look for this path "/root/.ssh/id_rsa" as my key pair is saved here. I know this question is silly, but please help me I am stuck right now.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

I have looked in EC2 dashboard, but can’t find there

>Solution :

When you run ssh-keygen and create a key pair, the keys are saved as files on your EC2 instance itself, not on the EC2 dashboard.

Since you generated the keys using sudo, they are stored in the /root/.ssh directory. You can view these files by running this in your EC2 instance:

sudo ls -l /root/.ssh/

Next, you need to display your public key using:

sudo cat /root/.ssh/id_rsa.pub
 

Copy the displayed key and go to your GitHub account settings, navigate to "SSH and GPG keys", click "New SSH key", paste your public key there, and save it.

Now that GitHub knows your public key, you can clone your private repository securely, from your EC2 instance.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading