Visual Studio Code SSH push and pull is working in command line but not with the push and pull buttons

Viewed 1461

I am trying to set up a programming environment for python with Visual Studio Code, git, and GitHub remote repo on Windows 10. I set up an SSH key and git repo on my local device. I then set up a repo on GitHub and added my SSH key to my account. I added the remote source on my local machine to point to the repo on gitHub.

I spent a while with connection issues and finally discovered I needed to enable the SSH service on my computer.

Once I got everything connected, I had an issue with merging the fetched repo that I overcame by adding the --allow-unrelated-histories flag. Once I added that flag the first time, I could push and pull freely with the remote repo using the command line on my local machine without using the flag. Any push or pull request would require me to enter my password.

I can use the Visual Studio Code to do everything with git on my local machine. Whenever I try to pull, I have the option to pull from the repo and select which branch I want to pull. However, when I actually try to pull using the pull to option, I get an error saying

Git: git@github.com: Permission denied (publickey).

My console output in VSC says

git@github.com: Permission denied (publickey). fatal: Could not read from remote repository.

Please make sure you have the correct access rights and the repository exists.

git show :Main.py

git status -z -u

git symbolic-ref --short HEAD

git rev-parse master

git rev-parse --symbolic-full-name master@{u}

git rev-list --left-right master...refs/remotes/origin/master

git for-each-ref --format %(refname) %(objectname) --sort -committerdate

git remote --verbose

Is this because, when using VSC's pull, it does not enter my SSH password automatically?

1 Answers

Check VSCode Enabling alternate SSH authentication methods:

If you are connecting to an SSH remote host and are either:

  • connecting with two-factor authentication,
  • using password authentication,
  • using an SSH key with a passphrase when the SSH Agent is not running or accessible,

...VS Code should automatically prompt you to enter needed information.
If you do not see the prompt, enable the remote.SSH.showLoginTerminal setting in VS Code. This setting displays the terminal whenever VS Code runs an SSH command.
You can then enter your auth code, password, or passphrase when the terminal appears.

But if your ssh-agent is running (as described here), make sure to launch VSCdoe from the CMD session where you have checked that said agent is working.

Related