I'm trying to push a file to a git repo of a friend but errors on public key.
git push origin testbranch Permission denied (publickey). fatal: Could not read from remote repository.
Where and how do we define public / private keys?
git remote -v
returns:
origin [email protected]:Sesamzaad/NET.git (fetch) origin [email protected]:Sesamzaad/NET.git (push)
Any help is appreciated.
In terminal enter this command with your ssh file name pbcopy < ~/. ssh/id_rsa. pub This will copy the file to your clipboard Now open you github account Go to Settings > SSH and GPG keys > New SSH key Enter title and paste the key from clipboard and save it. Voila you're done.
"Permission denied (publickey)" and "Authentication failed, permission denied" errors occur if: You're trying to connect using the wrong user name for your AMI. The file permissions within the operating system are incorrect on the instance. The incorrect SSH public key (. pub) file is in the authorized_keys file.
GitHub's Permission denied (publickey) error is usually caused by one of the following three issues: You have used an incorrect email address in the GitHub SSH URL. You have not configured your public SSH key in your GitHub account. You must create GitHub SSH keys to be used by the secure shell.
The “Permission denied (publickey). fatal: Could not read from remote repository” error is caused by an issue with the way in which you authenticate with a Git repository. To solve this error, make sure your key is being used on your Git account. If it is not, add your key to Git.
I was facing same problem, here is what I did that worked for me.
Use ssh instead of http. Remove origin if its http.
git remote rm origin
Add ssh url
git remote add origin [email protected]:<username>/<repo>.git
Generate ssh key inside .ssh/ folder. It will ask for path and passphrase where you can just press enter and proceed.
cd ~/.ssh ssh-keygen
Copy the key. You can view your key using. If you hadn't specified a different path then this is the default one.
cat ~/.ssh/id_rsa.pub
Add this key to your github account. Next do
ssh -T [email protected]
You will get a welcome message in your console.
cd into to your project folder. git push -u origin master
now works!
I just had to deal with this issue. @user3445140's answer helped me, but was much more than I needed to do.
cat ~/.ssh/id_rsa.pub
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With