VSCode Keep asking for passphrase of SSH key

Yes, you can avoid this prompt, without removing the passphrase.

To do so is usually fairly simple and relies on the ssh-agent program. First, before starting VSCode, at a bash shell prompt, run:

$ eval `ssh-agent`

This will start an ssh-agent process in the background that will remember the decrypted private key in its memory. The reason for eval is ssh-agent prints two environment variable settings that need to be added to the shell. (You can also just run it normally, then manually copy and paste its output back into the shell.)

Next, run:

$ ssh-add

This will prompt you for your passphrase, after which ssh-agent will provide private key services to any other process that needs it.

Finally, start VSCode from the same shell you ran the first command:

$ code

This way VSCode will inherit the environment variables it needs to get key services from ssh-agent, and therefore will not prompt for your passphrase so long as the ssh-agent process continues running.

Further References

Unfortunately, despite it being so useful, good (concise, readable) documentation on ssh-agent is hard to find. But here are some possibilities:

  • The man page is, as is typical for man pages, heavy on detail and light on examples.

  • The article http://rabexc.org/posts/using-ssh-agent is pretty good, and it covers some more advanced situations, especially agent forwarding.

  • The Stack Exchange question, “what’s the purpose of ssh-agent?” is also good.

Leave a Comment