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 protected]" -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.
I have looked in EC2 dashboard, but can't find there
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.