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.
For me I tried this -
eval "$(ssh-agent -s)"
then I run
ssh-add ~/.ssh/path-to-the-keyfile
and for generating the key you can run
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
this will generate the pair of keys (Public and private).
you can store this key to github for more read this Adding a new SSH key to your GitHub account
I hope it will help others :)
If you are using the GitHub for Mac UI, check preferences to make sure you're logged in.
I was getting this error. Turns out I had just upgraded OSX to Sierra and my old key was no longer registered.
At first I thought it was "Upgrading to macOS Sierra will break your SSH keys and lock you out of your own servers"
But I had sidestepped that one. Turns out I just had to re-register my existing key:
ssh-add -K
And type the passphrase... done!
this worked for me:
1- remove all origins
git remote rm origin
(cf. https://www.kernel.org/pub/software/scm/git/docs/git-remote.html)
*remote : "Manage the set of repositories ("remotes") whose branches you track.
*rm : "Remove the remote named . All remote-tracking branches and configuration settings for the remote are removed."
2- check all has been removed :
git remote -v
3- add new origin master
git remote add origin git@github.com:YOUR-GIT/YOUR-REPO.git
that's all folks!
I found this page while searching for a solution to a similar error message using git pull
on a remote host:
$ git pull
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
I was connected from my local machine to the remote host via ssh -AY remote_hostname
. This is not a solution to OP's question, but useful for others who come across this page, so posting it here.
Note that in my case, git pull
works fine on my local machine (that is, ssh key had been set up, and added to the GitHub account, etc). I solved my issue by adding this to ~/.ssh/config
on my laptop:
Host *
ForwardAgent yes
I then re-connected to the remote host with ssh -AY remote_hostname
, and git pull
now worked. The change in the config enables to forward my ssh keypair from my local machine to any host. The -A
option to ssh
actually forwards it in that ssh session. See more details here.
Did you create a config file in your ~/.ssh directory? It should have contents like these:
Host github.com
IdentityFile ~/.ssh/github_rsa
Assuming that you created an ssh key named github_rsa
and uploaded it to GitHub...
NOTE: You must follow this way of explicit configuration if you have more than 1 key (2 and more) in your ~/.ssh/ directory. If you don't specify key this way, then first key in order is taken and used for github authentication, so it depends on the key file name then.