In this post, we will discuss one of the GitHub errors that can occur when accessing code from a private repository. I recently encountered this issue when I tried to clone a private repository without adding my SSH key to my GitHub account.
The error message is,
The error message is,
C://WS/repo> git clone "URL Of PrivateRepo"
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.- Create new SSH Key:-
Open a terminal in any directory and run the following command:
$ ssh-keygen -t rsa -b 4096 -C "type your email here"
After enter the above command, then need to enter file name to save the ssh key, by default it should save in the home directory of ssh folder.
Generating public/private rsa key pair.
Enter file in which to save the key (/home/administrator/.ssh/id_rsa):
Then enter the passphrase, or leave as it is just enter,
Enter passphrase (empty for no passphrase): [Type a passphrase]
After running all above commands, the SSH key will generate and it will save mentioned directory.
dir/id_rsa , dir/id_rsa.pub
Copy the contents from id_rsa.pub file, and key should start with ssh-rsa,
and you can add into github account.
- Add generated SSH key to GitHub account:--
Login to your GitHub account using basic credentials, i.e username/email and password.
Then go to Setting -> SSH and GPG keys
Click on New SSH Key,
Give key title, then add the generated key in the text box, key should start with ssh-rsa or ssh-dss or above mentioned text.
click on Add SSH key. It will add into the GitHub account.
Enable the key as follows,
If you follow the above steps correctly, you will be able to access the code from the private repository.
If you have any questions or need further clarification, please leave a comment in the comments section.
If you have any questions or need further clarification, please leave a comment in the comments section.
Thank you for reading!



No comments:
Post a Comment