Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
+7 votes
3 views
in DevOps and Agile by (19.4k points)
edited by

Has anybody seen this error and know what to do?

I'm using the terminal, I'm in the root, the GitHub repository exists and I don't know what to do now.

> git push -u origin master

Permission denied (publickey).

fatal: Could not read from remote repository.

Please make sure you have the correct access rights

and the repository exists.

1 Answer

+7 votes
by (27.5k points)
edited by

Step 1: First, create the SSH keys by using the following command:  

$ ssh-keygen -t rsa -C "[email protected]"

It will create both id_rsa and id_rsa.pub files for you

Step 2: Now add the id_rsa to ssh list on local computer using the following command: 

$ ssh-add ~/.ssh/id_rsa.

Step 3: After generating the keys get the pubkey using:

$ cat ~/.ssh/id_rsa.pub 

You will get something like :

ssh-rsa AAAB3NzaC1yc2EAAAADAQABAAACAQCvMzmFEUPvaA1AFEBH6zGIF3N6pVE2SJv9V1MHgEwk4C7xovdk7Lr4LDoqEcqxgeJftwWQWWVrWWf7q9qCdHTAanH2Q5vx5nZjLB+B7saksehVOPWDR/MOSpVcr5bwIjf8dc8u5S8h24uBlguGkX+4lFJ+zwhiuwJlhykMvs5py1gD2hy+hvOs1Y17JPWhVVesGV3tlmtbfVolEiv9KShgkk3Hq56fyl+QmPzX1jya4TIC3k55FTzwRWBd+IpblbrGlrIBS6hvpHQpgUs47nSHLEHTn0Xmn6Q== [email protected]

Step 4: Now all you need to do is copy this key (value) and go to github.com and under the setting (ssh and pgp key) add your public key.

For more information regarding git commands please go through the following link:

If you want to read more about it, you should read Git Tutorial and you can also enroll in Git and Git Hub Training to learn about it in detail. 

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...