dawn
dawn

Reputation: 1342

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.

Upvotes: 24

Views: 51208

Answers (3)

bail.organa
bail.organa

Reputation: 41

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

Upvotes: 4

Nicolas HERMET
Nicolas HERMET

Reputation: 140

There are many ways you can make your ssh key (with a passphrase) works in the gitbash terminal for VS Code. I'll let you look around to find it if you didn't.

I assume you did look around and are still stuck because you want to use the UI of VSCode.

If so, this official page tells you why :

Basically, you'll still have to run it via git bash or via running ssh-agent.

But you can bypass the situation using putty. I didn't try it myself.

Anyway : hope it'll help.

Upvotes: 3

Madhu Bhat
Madhu Bhat

Reputation: 15173

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.

Upvotes: 25

Related Questions