With a new work laptop running Windows 10, I have installed git, Visual Studio Code and Visual Studio 2019. After making some test changes to code in from my personal git repo (hosted on github), I am trying to commit and push those changes to the remote repo.
I can perform all of the Stage, Commit and Push actions from Git Bash. But in Git Gui, VS Code and VS 2019, Stage and Commit both work fine, but Push fails with an error message.
For VS Code the error is:
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.
And for VS 2019 the error is similar:
git@github.com: Permission denied (publickey).
Error encountered while pushing to the remote repository: Git failed with a fatal error.
Could not read from remote repository.
How do I resolve this?
Update
The comment from @DaemonPainter helped lead to the answer. My private SSH key files were named id_rsa_github and id_rsa_github.pub. Visual Studio 2019, Code and Git Gui all expect these to be named id_rsa and id_rsa.pub.
The solution is to add a config file to %HOMEPATH%\.ssh with contents similar to this:
host github.com
HostName github.com
IdentityFile ~/.ssh/id_rsa_github
After making that change, git push works in Git Bash, Gut Gui, VS Code and Visual Studio.