GitHub: Permission denied (publickey). fatal: Could not read from remote repository

I´m having trouble with GitHub. I´ve playing around with a remote repository of Git.

When I now try to make any changes to the remote directory, i.e.

git remote show origin


git push -u origin master

I get this error

Permission denied (publickey). fatal: Could not read from remote repository.

Please make sure you have the correct access rights and the repository exists. Ulrichs-MacBook-Pro:coredatatest ulrichheinelt$ git push -u origin master Permission denied (publickey). fatal: Could not read from remote repository.

I would be happy, when I could start again with a new (empty) remote directory. Or is there a way, to fix this error?

This are my first steps with GitHub, started yesterday… Many thanks in advance!

Edit 1

my settings at

Edit 2

too early happy 🙁

After setting the SSH and GPG keys, the errors are still the same. :-/

Edit 3

I think that’s right so, but still the same…

enter image description here

9 Answers

  • On your GitHub profile there is an Edit Profile button.
    It is located on top-right corner of the webpage.
  • Press it and you will see left Personal Settings menu.
  • Inside that menu find SSH and GPG keys option and press it.
  • You will see an option New SSH key to add new key.
  1. Generate SSH key using ssh-keygen -t rsa -b 4096 -C "your email".
  2. Copy the output of cat ~/.ssh/ to your clipboard
  3. Paste the above copied output to the form at
  1. generate your key


  2. Visualize your keys

    ls ~/.ssh


  3. Start the agent

    eval ssh-agent

  4. Add your key to the agent

    ssh-add ~/.ssh/id_rsa

I was having the same problem with my ssh connection. I tried to work it through ssh, but couldn’t find a working solution for it. So, in that case, I changed my remote URL from SSH to HTTPS. I used the command: $ git remote set-url origin You can see your remote url changed using: $ git remote -v.

You can find more detail on Here

This will change your remote URL to HTTPS so you will now have to type your GitHub username and password to push your project to the remote repo. I know ssh is easier than HTTPS meaning that you don’t have to type out your username and password, but this might be helpful if you didn’t find any solution for fixing it through ssh, and you are in a rush to push your code to your repo.

For me I had to set what host to use what SSH key. In your local machine SSH folder, usually under ~/.ssh create/edit the file called config using your preferred editor like vim or gedit

vim ~/.ssh/config

and add the following with your git Host, HostName, and ssh IdentityFile (your ssh private key file path):

    IdentityFile /home/YOURUSERNAME/.ssh/id_rsa

  1. make sure you have named the “public key” and “private key” files properly; precisely like “id_rsa” and “”. This is something that you can find in your users/.ssh folder.

  2. add the public key in GitHub

  3. Restart your terminal ( bash supported) and try to clone again

if you have the write access to the repo, you should be good to go after these changes.

Talking from experience (after spending an hour), I could not find any info on any forum that stated that we have to explicitly keep the name of the private and public file as mentioned above.

Happy coding!

If any of you facing same kind of issue on Bitbucket then here is the solution:


[email protected] MINGW64 /u/works (master) $ git clone ssh://[email protected]:5449/rem/jenkinspipeline.git Cloning into ‘jenkinspipeline’… [email protected]: Permission denied (publickey). fatal: Could not read from remote repository.

Please make sure you have the correct access rights and the repository exists.

[email protected] MINGW64 /u/works (master) $ cat < ~/.ssh/ ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC99aqMXtBpVvCQb6mezTHsftC3CFY9VOpGaNmckmcTzXoOOWOheeM9V2NTrOWxpbE3UNdL/6ZnmPyv5EI2zPMPstVIP5jAqcmxOvGc2zxy4wHeGTgrP6UaXs2nLScV4E7+rmdaVtSsfOa1i+eU2eg4UnIJpRLtGD6N+hMKJXaXWpGfQ79USiPhPQKDGOz3PeEDggyvHs7HUzaKZpwEeIKYOSDXsvDwTJ6s5uQ30YfX3eoQbAis8TJeQejAmkuu62oSOs5zFJMSTAzakiyXW/xCUsLrnUSzxmBKO2BIA/tSTrqW/Gj0VhDniDFGwGz0K1NfLzfEJLWKvdB2EJWVFjEd [email protected]

Goto: 1) Add keys Copy/paste the key value there:

enter image description here
Done! Now you can able to clone the git repository

[email protected] MINGW64 /u/works (master) $ git clone ssh://[email protected]:5449/rem/jenkinspipeline.git Cloning into ‘jenkinspipeline’… remote: Enumerating objects: 1146, done. remote: Counting objects: 100% (1146/1146), done. remote: Compressing objects: 100% (987/987), done. remote: Total 1146 (delta 465), reused 0 (delta 0) Receiving objects: 100% (1146/1146), 149.53 KiB | 172.00 KiB/s, done. Resolving deltas: 100% (465/465), done.

I got it after wasting a lot of time…

In the accepted answer of Shravan40 everything was ok, but me idiot added at a new repository with adding a new and this caused the error

 ERROR: Repository not found.
 fatal: Could not read from remote repository.
 Please make sure you have the correct access rights

after a lot of tries, i added a new repository without a new and everything was ok, but i don´t know the reason. 🙁 Till yesterday, when on a new try i finally noticed it…

So my solution in addition to Shravan40s answer is

enter image description here

maybe it will help someone…

In my short experience using git with linux, I found there were two simple answers to this error.

run these commands in this order

git remote set-url --add origin <>
git remote set-url --delete origin <[email protected]:username/repo>

This will reconfigure your config file to use HTTPS origin instead of SSH.

now try running push or pull commands.


Reboot your linux VM (if you’re using one) and/or host machine. Rebooting has resolved the issue for me more than once.

Leave a Reply

Your email address will not be published. Required fields are marked *