VS Code IDE with Passphrased Git SSH Keys

Access Denied (by https://www.flickr.com/photos/raidokaldma/)I’m just kicking the tires with Visual Studio Code. So far, it seems like a nice little editor! One thing that tripped me up a bit was the Git integration… permission denied errors due to git ssh keys that use passphrases.

Here’s how I solved it…


For some of my hosted repo’s, I use an SSH key instead of a username/password. That key has a passphrase on it.

Git Error: Permission Denied

When I opened that codebase in VS Code, the Git screens complained that it could not connect. The output from VS Code showed:

git fetch
Permission denied, please try again.
Permission denied, please try again.
Permission denied (publickey,gssapi-with-mic,password).
fatal: Could not read from remote repository.


My first step was to make sure that, from a windows command prompt, I could execute “git fetch” without any authorization prompts. SSH-AGENT is supposed to make this happen.

This works fine in the bash window, but is more troublesome from a standard command prompt. A bit of digging lead me to the “start-ssh-agent.cmd” batch file that’s installed with Git. That launches the ssh-agent and prompts me for the passphrases to the keys in my .ssh folder.

I enter the passphrase once and then git stops prompting me. Beautiful.


VS Code still threw permission denied errors at me. Investigating the SSH-AGENT situation a bit, it looks like the agent uses some environment variables. Those are set on the current command prompt, but VS code was launched with a separate environment. So VS Code didn’t seem to pick up or use the SSH-AGENT.

Step 2: Launch VS Code from Command Line

My solution was to follow this flow:

  1. Open a command prompt.
  2. Run “start-ssh-agent” and answer passphrase prompts.
  3. Run “code” to launch VS Code from that environment.


I’d love to hear if there is a better, cleaner, simpler way to make this work. Drop comment if you have a thought.


(Photo by https://www.flickr.com/photos/bill_harrison/)

4 thoughts on “VS Code IDE with Passphrased Git SSH Keys

Add yours

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Create a website or blog at WordPress.com

Up ↑

%d bloggers like this: