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.
5 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.
-
Mint XFCE 19.3: this worked for me until reboot. I created a new RSA key with Seahorse and this seems persistent– PhilJun 15, 2020 at 9:43
For Windows 10, if you have stumbled across this issue using the Remote - SSH plugin, run the following in powershell (as admin):
# Make sure you're running PowerShell as an Administrator
Set-Service ssh-agent -StartupType Automatic
Start-Service ssh-agent
Get-Service ssh-agent
(As suggested by the documentation that is pointed to by this comment on a git (non-)issue.)
-
Can also call
ssh-add
in your powershell init scripts, eg:$HOME\Documents\PowerShell\Microsoft.PowerShell_profile.ps1
– EfrenMay 17, 2021 at 7:28 -
@darmual Doing the
ssh-add
afterwards in the vscode terminal did the job for me +1 Oct 11, 2022 at 7:43 -
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.
There is a great guide on how to solve it in Windows here:
https://www.cgranade.com/blog/2016/06/06/ssh-keys-in-vscode.html
Summary:
- Install Required Software (Putty)
- Setup Private Keys (use ssh-keygen which will create private and public keys in .ssh folder)
- Set up SSH Agent: have Pageant tool run on Windows startup
- import your key to ppk format
Run PuTTYgen from the Start Menu and select File → Load Key.... From there, navigate to C:\Users\.ssh\ and select id_rsa (the private key). You may have to drop down the file types selector in the dialog box to see this, as PuTTYgen defaults to filtering out everything but files ending in *.ppk. Once selected, you’ll be prompted by PuTTY to unlock your key by typing in your passphrase. Do so, and PuTTYgen will show the corresponding public key. Select File → Save private key to export your private key in PuTTY, rather than OpenSSH, format. I suggest saving it as id_rsa.ppk in the same folder as id_rsa
- run Pageant
Finally, run Pageant from the Start Menu (in the future, this will be handled automatically by the shortcut we created above). This will add a new icon to your system tray. It may be hidden by the arrow; if so, click the arrow to make all fo the system tray icons visible. Right-click on Pageant and select Add Key. Browse to where you saved id_rsa.ppk and select it. You’ll be prompted to unlock your key. Upon doing so, your unlocked key will then be made available in Pageant until you log out or quit Pageant.
Add fingerprints, in shell run one of those two (depending on your needs)
'C:\Program Files (x86)\PuTTY\plink.exe' git@github.com
'C:\Program Files (x86)\PuTTY\plink.exe' git@bitbucket.org
Configure GIT_SSH to be C:\Program Files (x86)\PuTTY\plink.exe
-
Updated my answer with details (summary only, tried to keep it short) Jan 9, 2020 at 23:22