Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VSCode Keep asking for passphrase of SSH key

I have recently upgrade my VSCode version 1.10.2. As I put passphrase on my private SSH key, it started to ask for it frequently even when I entered it multiple times, which is very annoying. Is there anyway I can get rid of it? Thanks. enter image description here

like image 298
Jonathon Avatar asked Mar 10 '17 00:03

Jonathon


People also ask

Where do I put SSH key in VS Code?

Add SSH key to your VM#Select Use existing public key in the dropdown for SSH public key source so that you can use the public key you just generated. Take the public key and paste it into your VM setup, by copying the entire contents of the id_ed25519. pub in the SSH public key.

Could not establish connection to failed to install the VS Code server?

Open the command panel (Ctrl+Shift+P for Windows and Cmd+Shift+P for Mac), search for Kill VS Code Server on Host, and locate the affected instance, which will be automatically cleared. Then, establish the connection again.


2 Answers

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.

like image 129
Scott McPeak Avatar answered Feb 27 '23 01:02

Scott McPeak


The only solution I've found was remove the passphrase:

ssh-keygen -p

It will ask your current passphrase and leave blank the new passphrase to remove it.

like image 24
Daniel Martínez Sarta Avatar answered Feb 27 '23 00:02

Daniel Martínez Sarta