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.
Assuming you are connecting GitHub over SSH, you can run below command to confirm this.
If you get a result has following format git@github.com:xxx/xxx.github.com.git, then you should do the following.
Generate a SSH key(or use existing one). if you had one, you just need to add your key to the ssh-agent (step 2)and to your GitHub account(step 3).
below are for those who don't have SSH key.
Step 1 Generating public/private rsa key pair.
You'll be asked to confirm where to save the SSH key and what passphrase you want to use.
Step 2 Add your key to the ssh-agent
Ensure ssh-agent is enabled
$eval "$(ssh-agent -s)"
Add your SSH key to the ssh-agent:
$ssh-add ~/.ssh/id_rsa
Step 3 Add your SSH key to your account
$sudo apt-get install xclip
$xclip -sel clip < ~/.ssh/id_rsa.pub
Then add the copied key to GitHub
Go to Settings->SSH keys(Personal settings side bar)->Add SSH key->fill out form(key is on your clipboard, just use ctrl+v)->Add key
After going through above steps, you should solve the permission problem.
Reference Link: Generating SSH keys.
this worked for me:
1- remove all origins
(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 :
3- add new origin master
that's all folks!
Go to your GitHub account dashboard, find your project repository, click Settings tab - under Deploy keys you'll have to add your SSH key. Open Terminal and type:
This will copy the key from your id_rsa.pub file. So just go back to GitHub dashboard, paste it, click Add Key and that's it.
The same solution applies to Bitbucket accounts.
I was using github earlier for one of my php project. While using github, I was using ssh instead of https. I had my machine set up like that and every time I used to commit and push the code, it would ask me my rsa key password.
After some days, I stopped working on the php project and forgot my rsa password. Recently, I started working on a java project and moved to bitbucket. Since, I had forgotten the password and there is no way to recover it I guess, I decided to use the https(recommended) protocol for the new project and got the same error asked in the question.
How I solved it?
Ran this command to tell my git to use https instead of ssh:
Remove any remote if any
Redo everything from git init to git push and it works!
PS: I also un-installed ssh from my machine during the debug process thinking that, removing it will fix the problem. Yes I know!! :)
you can use Https url to login
i guess you are trying to login with ssh url when you say git push if it as asking only password consider you are connecting through ssh.better you use http url.
You need to generate an SSH key (if you don't have one) and associate the public key with your Github account. See Github's own documentation.