Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't push to remote SSH repo on GitHub via VSCode

I already updated my Git for Windows. I checked the keys are correct. The only "solution" is to start

ssh-agent

Or opening VSCode via Git Bash.

So, any useful solution?

Log:

> git push origin master:master
[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.
like image 501
dawn Avatar asked Sep 13 '18 03:09

dawn


People also ask

How add SSH key to VS Code?

Add SSH key to your VM# Select Use existing public key in the dropdown for SSH public key source so that you can use the public key you just generated. Take the public key and paste it into your VM setup, by copying the entire contents of the id_ed25519. pub in the SSH public key.


2 Answers

You could set an remote origin using an access token (in Github) like:
git remote set-url origin https://[email protected]/your-account/your-repo.git

like image 44
bail.organa Avatar answered Oct 03 '22 21:10

bail.organa


Force push might be disabled on the master branch. Check the settings on the repo that you're trying to push to.

If force push on master is not disabled, you need to make sure that you have added your ssh key path on your ssh config, so that you don't have to add the ssh key to the session every time. Edit the config file at ~/.ssh/config and add the below (on MacOS)

Host *
  UseKeychain yes
  AddKeysToAgent yes
  IdentityFile ~/path/to/key

For Windows, please check my SO answer to know how to add the ssh key to the ssh config.

UPDATE

Looks like there's an open issue with VS Code on Windows here. You may try the workaround that is mentioned here.

like image 200
Madhu Bhat Avatar answered Oct 03 '22 22:10

Madhu Bhat