Vscode: Git: Support git with private key password

Created on 13 Oct 2016  ·  229Comments  ·  Source: microsoft/vscode

  • VSCode Version: 1.6.0
  • Commit e52fb0bc87e6f5c8f144e172639891d8d8c9aa55
  • Date 2016-10-10T18:37:40.189Z
  • Shell 1.3.7
  • Renderer 52.0.2743.82
  • Node 6.5.0
  • OS Version: Windows 7 Pro

Steps to Reproduce:

  1. Create a public-private key pair with password protection
  2. add them to your github account
  3. setup git to use the private key file
  4. try to push something with git

Result:

git pull
Permission denied, please try again.
Permission denied, please try again.
Permission denied (publickey,password).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
feature-request git help wanted

Most helpful comment

A workaround for Windows 10:

  1. Make Git use the OpenSSH that comes with Windows instead of the one that comes with Git.
    git config --global core.sshCommand "C:/Windows/System32/OpenSSH/ssh.exe"
  2. Set the ssh-agent service (not the one that comes with git) to run automatically.
    Open Task Manager, Services tab, click Open Services.
    Find OpenSSH Authentication Agent, open properties, set Startup Type to Automatic, hit OK.
    Also start the service or restart your computer.
  3. Add your password protected key to the agent.
    ssh-add
    It should automatically pick up keys stored in C:\Users\%USERNAME%\.ssh which is where ssh-keygen creates them.
    Enter your password(s) at the prompt.

Note: If, when installing Git for Windows, you selected the option to add bash commands to PATH, the ssh-add command might point to the wrong executable. If so, you can manually run the included one to get your key added to the agent:
C:\Windows\System32\OpenSSH\ssh-add.exe

Now the built-in OpenSSH auth agent will run on start up with your password protected key unlocked, and Git will use the Windows OpenSSH instead of it's own. So no need to type in your password every time, no need to manually start the ssh agent, and no need to start VS Code from command line.

All 229 comments

Does it work from the command line? How exactly do you setup git to use the private key file?

It works from the command line. Actually I setup git via tortoise git - so I guess all is properly done.

image

How do you launch the command line? Which command line?

I use git bash (MINGW64) on windows.

Right. So, we might have to add a git.sshkey setting too, like Tortoise.

With Windows 10, Git 2.10.1.

Had problems using git on vscode with my production server, so I created a test server.
At first, with a password protected user (no keys), same errors - no credential prompt pop ups or anything.
Using the terminal inside vscode or any random cmd I can push, pull and it works - asks for password. With vscode I can only prepare commits. Pull, push, sync all fail because they aren't asking for password.

In production I'm using a passphrase protected key with a different 5 digit port for ssh.
Also I have a few different ssh keys (including git) on one machine...

@joaomoreno Why did you moved it to the backlog?

Just planning priorities. You can attempt a pull request though. 👍

Waiting for it 😉

Any update on this? I'm having the same problem and it's pretty annoying 😞

@joaomoreno I'm taking a stab at this. It affects me personally now as I recently moved to key based security.

People can track my progress here.

@hashhar That's awesome! 🍻 Let me know if you hit some walls.

@joaomoreno I was looking into the places that need change and found the following:

Current Scenario:

  • If you have an ssh agent running with the key added to it, you can perform all operations except clone (because node.url.parse() doesn't work for ssh urls).
  • If ssh-agent is not running all git commands that involve network activity (fetch, clone, push, pull) fail. The error is generated by git.exe.

Proposed Changes:

  • [x] Not needed, see next comment Add an overload to url.parse() (where?) to make sure ssh urls are also recognised.
  • [x] Add a config key, git.sshkey (location of private key (limited to openssh keys at the moment - because git supports those natively, will look into putty keys later)).
  • [ ] Add a conditional where the git extension is initialised to start an SSH agent (if one is not running) and add the key. Will need to somehow (quickpick?) ask user to enter their passphrase. (Do we kill the agent when we close vscode?)

No other changes will be necessary (from what I've currently seen) because the communication with the git endpoint is handled by git.exe not by vscode.

Okay, my bad about the url parsing. Seems like node accepts urls like git+ssh://[email protected]:hashhar/vscode or ssh://[email protected]:hashhar/vscode but the ssh part has to be explicitly mentioned.

What should I do about this, should vscode just magically prepend ssh before urls that match [email protected]:username/repo format. Or fail silently? (This still needs ssh-agent running though).

Ping @joaomoreno. If you can find the time, do comment on the above issues I have. I have currently hacked together a proof of concept by starting the ssh-agent against a private key. It works but some polish is still needed.

@hashhar Sorry for the delay... I'm actually quite busy at the moment. Feel free to create the PR and move the discussion there, we'll try to get it in for March.

It's not enough to just start ssh-agent, you need to also add the environment variables SSH_AGENT_PID and SSH_AUTH_SOCK so that Git knows where to look.

You'll then need to either store this somewhere, so that it can be used between restarts of VSCode, or you'll need to restart ssh-agent every time you restart VS Code.

It would be lovely if it could share this with Posh-Git (the Powershell Git module), which stores the values in ([System.IO.Path]::GetTempPath()) ".ssh\$key.env" - but possibly worth talking to that team to make sure that that location is something they're happy to be locked to.

@andrewducker Thanks a lot for the additional input. I've haven't been working on this on the pace that I would like to because of my mid-sems. I'll get back to it by the end of the week. I'll let the Posh-Git team know.

@joaomoreno I've got back to working on this. My previous approach was too naive and didn't work. I'm currently trying to find a suitable place to add a function that is called before performing any git command (ie. when VSCode starts up and the git provider is loading). Where do I do this? I can't seem to understand what is the flow of code.

Is there a piece of code which is called whenever a Git call is made? If so then you could ask for the password the first time it's called.

Looking at it, putting a hook into Git.ts would be the way to go, inside around any functions which would mean connecting to the server. (Like fetch, pull, push, etc).

(I'd offer to do this myself, but I've never written anything in TypeScript, or worked with VSCode extensions, so this is just based on me briefly digging through the code on GitHub.)

The biggest problem is that on Windows the SSH_AUTH_SOCK and SSH_AUTH_PID variables may be available to all processes or just a single console session depending on how ssh-agent was started. So it is far easier to start a ssh-agent from within VSCode instead of reusing existing ones (at least on Windows).

In practical terms this means that the user will have to supply their passphrase ONCE before the first Git operation is done. The VSCode instances can share the ssh-agents among themselves if we can define a hardcoded place where SSH_AUTH_SOCK was going to be created so that other VSCode instances can look at them before starting their own agents.

This is turning out to be quite an interesting challenge for me. 😃

It would also be a viable option if vscode would honor an already existing SSH_AUTH_SOCK. I'm being asked for my private key password even though ssh-agent is already running on my system. Interestingly I can use git within the integrated vscode terminal (shell) fine. The git plugin and the terminal should behave the same for easier debugging.

EDIT: I'm on commit f9d0c687ff2ea7aabd85fb9a43129117c0ecf519
EDIT2: It works when I run vscode from a bash instead of using my window manager's launcher.

Yes - starting VSCode from a session that already has them set in the environment works perfectly (Launching from Powershell in my case). So if they're already set then there's nothing to do.

any progress on this?

@ezamelczyk Nope. I'm sorry. I haven't been able to put enough time into it owing to college. Thanks for reminding me btw. I'll try to get some work done the coming week.

Hi everyone,

Sadly I'm having the same kind of issue... 😭
Here is my config and the detailed scenario to reproduce it.
I hope it'll help a little!

OS : macOSX Sierra Version 10.24.4
VScode: Version 1.11.1

In my .ssh folder I have those files:

  • config
  • id_rsa_github
  • id_rsa_github.pub
  • id_rsa_gitlab
  • id_rsa_gitlab.pub
  • know_hosts

The config file content:

Host gitlab.com
  HostName gitlab.com
  User git
  RSAAuthentication yes
  IdentityFile ~/.ssh/id_rsa_gitlab

Host github.com
  HostName github.com
  User git
  RSAAuthentication yes
  IdentityFile ~/.ssh/id_rsa_github

I can commit and push without any problem from the command line and tower.
But I can't in VScode... it returns me this output message each time I try:

git pull
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.

Thanks for your help

For me this is really a blocker. I like VSC, but without the ability to use git I can't use it as my daily editor.

@MartinZubek @jmbelloteau Does launching it from a command line where you've started SSH Agent fix it for you?

@andrewducker

From terminal I've connect to my remote Git with the command:

ssh -T [email protected]

...then I've open VScode from terminal with the command:

code

When I push from VScode I still get the same error...
That's really a problem !

@MartinZubek same here, VScode is amazing, much more than Atom.
I love the speed the integrated terminal the UX and the possibility to use git.

But we also need connection to remote GIT to be secure. That's mean password protect SSH...

It makes sens... right?

@andrewducker Indeed it does work for me this way. :)
Any chance it will work natively without need to start it from command line?

Hi @MartinZubek,

What does work for you? Can you be more specific? 😄

@jmbelloteau Sure, it no longer ends with "Permission denied (publickey)" error and git pull/push works as they are supposed to. It uses the correct key from the ~/.ssh/config file and whenever the key passphrase is needed, this window pops-up:
http://imgur.com/wpExMMP

@MartinZubek so you can push from VScode?! That's great...
Did you launch it from a command line where you've started SSH Agent?
If yes how?
I don't understand why it doesn't work on my environment

@jmbelloteau Yes, I launched vscode from command line I use (it is the git-bash.exe which comes with git for windows by default, to be exact). I didn't have to start the ssh-agent or anything manually though. I guess it starts automatically with git-bash or something.

@MartinZubek damn it...

Even like you said it doesn't work for me 😭

@vscodeteam Any plan to handle this problem ?

@jmbelloteau It's too damn difficult. It's also quite hit and miss. What I've tried implementing was to start a ssh-agent under the node process so that the env variables are available to VSCode but that means that multiple VSCode instances will need multiple ssh-agents and still require passphrases to be entered everytime.

I'm looking at a way to use the SSH_AUTH_SOCK variable instead. It works on Linux but have yet to test it on Windows.

There's the added issue of OpenSSH vs Windows Powershell SSH vs PuTTY.

If anybody is willing to test it, I can push the code to my fork and people can test it. It'll take some time though since I have used harcoded paths (proof of concept thing).

I think I'll have it up by Saturday or Sunday.

Hi @hashhar !

Thanks for your answer.
Indeed it seems really complicated. 😞

I'm not really developer so I can't really help you, I'll just keep around in case you found the magic and send you good luck !

@hashhar regarding your comments, I do have 2 options to suggest:

  1. You can go for restarting the whole VSCode (including the ancestor node process) under ssh-agent, run by ssh-agent path/to/code; in this way, there is no need to run one instance of ssh-agent for each node process.
  2. You can run ssh-agent from a node process, get the environment variables (e.g. print them on a file) and share them through all the processes.

I can definetely test. Do I need something particular to build it? I have installed the official version.
I can build it though :)

@joaomoreno I think I have a partial fix ready.

In the file extensions/git/src/askpass.ts, I changed getEnv() to:

getEnv(): Promise<any> {
        return this.portPromise.then(port => ({
            ELECTRON_RUN_AS_NODE: '1',
            GIT_ASKPASS: path.join(__dirname, 'askpass.sh'),
            VSCODE_GIT_ASKPASS_NODE: process.execPath,
            VSCODE_GIT_ASKPASS_MAIN: path.join(__dirname, 'askpass-main.js'),
            VSCODE_GIT_ASKPASS_PORT: String(port),
            SSH_AUTH_SOCK: process.env['SSH_AUTH_SOCK'],
            SSH_AGENT_PID: process.env['SSH_AGENT_PID'],
            SSH_ASKPASS: process.env['SSH_ASKPASS'] || '/usr/lib/ssh/x11-ssh-askpass'
        }));
    }

The SSH_AUTH_SOCK is picked from user's environment if set.

The following things are now possible:

| ssh-agent | ssh key loaded in agent | result|
|:---:|:---:|:---:|
| ✔ | ✔ | ✔ |
| ✔ | ✘ | $SSH_ASKPASS is executed |
| ✘ | ✘ | nothing happens |

So to fix the issue in the 2nd row, we can set SSH_ASKPASS from askpass.ts too and that causes VSCode to launch the program on startup and ask for SSH keys passphrases.

For the final row though, we'd need to start a ssh-agent from within VSCode and set the proper variables.

Volunteers?

If somebody's willing to test this, you can clone my fork (https://github.com/hashhar/vscode), switch to the git-ssh-key branch and build it and run it. Please try checking what happens on all combinations from the table above. To keep the noise here minimum, you can comment on this issue.

@hashhar The entire process.env is always passed to Git when spawning it:

https://github.com/Microsoft/vscode/blob/master/extensions/git/src/git.ts#L383

Don't those variables get passed without your snippet?

@joaomoreno Okay. Digging deeper shows me two issues.

  1. VSCode apparently doesn't use the variable SSH_ASKPASS. It is hardcoded to '/usr/lib/ssh-ssh-askpass'. Basically the only issue is that VSCode doesn't assist Git by telling it how to launch a prompt for getting the user's ssh-key passphrase.

Most tools on linux provide a program symlinked to '/usr/lib/ssh/ssh-askpass' but many do not. So that's an issue that I think people are hitting.

I've been able to use VSCode with SSH as long as the ssh-key was already added to the ssh-agent keyring.

I think I've been stupid.

TODO:

  1. Extend vscode-askpass.ts etc. for ssh too.
  2. Start ssh-agent if not already running. This is just a convinience issue otherwise you'd have to enter the passphrase for each git operation.

I'm sorry for not working thoroughly.

No worries, it's cool that you're jumping on this! 👍

I've been encountering this error for a while now, and thought it was me. Any more progress on this?

+1

+1

+1

+1

Please, stop spam! Use subscribe button and reaction button and do not write such useless comments.

I too get the same issue.

image

Oddly, for me this works in Git Bash, but not in Bash for Windows (where I get the aforementioned Permission denied (publickey) error):

$ eval `ssh-agent`
$ ssh-add /path/to/key
$ code

I can verify that the SSH key works by sshing directly to the remote in both cases; the only difference I can see is that on startup in Bash for Windows, VSCode warns that it can't determine the current working directory.

Same issue here, i have tried almost all suggested solutions.

I'm on MacOs

@DavidBabel I am on MacOs and temporarily bypassing the issue by using the ssh key without passphrase...

@letsdevus Thanks for the help, but unfortunately it's not feasible in a professional context

The only way I found out for making it work was to:

  1. Install PuTTY suite
  2. Set plink as the Git SSH backend (with the environment variable GIT_SSH)
  3. Add to PuTTYgen your access key
  4. Before all the operations, in a command prompt, use plink to connect to the service you want to use

This does the trick.

Hitting the same issue, and as it keeps retrying its knocking on the perf of VSCode too 👎

Just came across this issue myself. Thankfully the workaround (starting code from shell) works for me, but would be nice if the issue was fixed.

Just bumped into this too the putty solution seems to help, but I would prefer not to have putty at all.

I'm dealing with this issue as well. I set up a separate account for work and have my personal one. I've been working with work files a lot lately. I'm able to get through but I have to enter the passphrase each time. Not a killer but a lot less productive.

Its a little disappointing that attempting to clone a repository using the VSC UI doesn't work using an ssh-style git URL. For the record I do use a password protected SSH key, and I frequently am not running SSH agent. I find the extra password prompt to unlock my key actually somewhat reassuring -- especially when pushing changes out. :-) Its not huge, because the command line works fine for me (for the record I'm running VS code on macOS.)

@gdamore so, it actually works for you, without an agent... But we are talking about Windows. 😝
Anyways, which is the name of the file of the SSH key? Is it a standard one? Or is VSCode good enough to find the proper file?

I run VScode mostly on macOS, as indicated. I have no idea how this works on Windows; I don't git commit from Windows, and instead rely upon shared filesystems (my Windows development instance runs as a guest within a VM on my mac.)

i'm getting this error too. no issues at all in command line, but unable to perform any git activity inside the app itself

making vscode useless as a git ide in a work context

I was able to make it work following this blog post:

http://www.cgranade.com/blog/2016/06/06/ssh-keys-in-vscode.html

Same issue on OSX with passphrase protected keys.

Simple solution:

Add a user environmental variable called GIT_SSH with path to C:\Program Files\PuTTY\plink.exe (after configuring the path to the private key using tortoise git)

This need to be fixed, it doesn't make VS Code a daily editor tho. :/ Any info about the progress of the issue?

Would love for vscode to obtain the ssh credentials from ssh-add.

For example, source tree is able to detect available credentials (using osxkeychain?), without any extra configuration

git -c diff.mnemonicprefix=false -c core.quotepath=false -c credential.helper=sourcetree commit -q -F /var/folders/_0/bvqq9l5d2ngg0stvkf53jrbr0000gn/T/SourceTreeTemp.ccbSGv 


git -c diff.mnemonicprefix=false -c core.quotepath=false -c credential.helper=sourcetree push -v --tags --set-upstream origin refs/heads/master:refs/heads/master 
Pushing to [email protected]:hanxue/gif-is-jif.git
To github.com:hanxue/gif-is-jif.git
   4eed265..762069a  master -> master
updating local tracking ref 'refs/remotes/origin/master'
Branch master set up to track remote branch master from origin.
Completed successfully

I faced this problem today, i'm in linux mint. i used keychain.

sudo apt install keychain

eval 'keychain --eval SSHKEY'
and that's it.

@Silentz0r where did you run the last command?

@ValentinH in your shell, read the example in the link.

Guys this is just waiting for a brave coder to provide a PR!

On OSX, I fix it thanks to https://github.com/jirsbek/SSH-keys-in-macOS-Sierra-keychain:

In ~/.ssh create config file with the following content:

Host * (asterisk for all hosts or add specific host)
  AddKeysToAgent yes
  UseKeychain yes
  IdentityFile <key> (e.g. ~/.ssh/userKey)

@joaomoreno
Not sure how "Brave" I am, but I am a bit of an SSH fan.
I will work on a PR for December.

All concerned citizens...

After a quick setup test it seems as though a Windows 7 configuration is quite straightforward (see GIT_SSH and other comments) I believe the comments that OS X using keychain is equally easy.
The set up is basically an external configuration issue. VSC does not need any configuration or feature changes to use SSH, git calls the SSH client . Sorry if I'm missing something obvious.

Other than a wizard for set up I'm trying to determine what would really be beneficial to add to code.
One comment mentions using more than one key which might require to change the environment variable presumably based on the workSpace configuration. Even that may all be handled by the agent. I don't think it makes sense to do anything like add ssh to Code as git takes care of this quite directly.

As for credential management: that really wants to be handled by a secure agent such as
pagent/keychain et cetera.

Comments?

"VSC does not need any configuration or feature changes to use SSH, git calls the SSH client . Sorry if I'm missing something obvious."

(On Windows)

What happens
If I launch VS Code from a shortcut, and have not also downloaded a third-party piece of software and carried out some command-line configuration, then it does not work with encrypted SSH keys.

On the other hand, if I open Eclipse and connect to a Git repository then it will ask me for the passphrase to my keys.

Expected
A fresh install of VSCode, on a system with no other software installed, should pop up a message box asking for my passphrase, and then use it to decrypt my keys and use them to connect to the remote repository.

@cleidigh SourceTree works automatically without following @ItachiSan's instructions, whereas Code requires that setup. Perhaps we could do whatever they're doing.

@andrewducker
@BeginnerForLife
I looked into Eclipse and source tree a bit. Unfortunately I currently cannot install either of these on my system so my knowledge and experience are limited by Google ;-) Keep that in mind if I'm missing something. Here is a basic synopsis/difference:

Eclipse: EGit plug-in: contains Java git client, ssh client appears to be internal, requires key import if existing key

SourceTree: graphical get client, requires external ssh client (from screenshot below assumes plink on Windows) @BeginnerForLife I think this set up is not that far from the current requirements.

image

VSC: Requires external git/ssh

@andrewducker your description tracks my comment, unless Code implements both git and SSH (including key generation and management) I am not sure there is much in between. While this could be done I'm skeptical that the team would want to pull in both of these. @joaomoreno can speak to that.
From a practical point of view I'd like to point out the following:

  • The "easy out-of-the-box" git experience is more aligned with using the built-in HTTPS, still requires external git
  • For those work situations where SSH is required, I would argue that there is very likely policy and ssh
    tools already in effect, that is what I have experienced in the various corporations I've worked for.
  • Assuming one agrees with the above, coupling to external tools would be the more likely scenario than
    setting up ssh/git from scratch or standalone.
  • To be clear, I in no way want to imply ssh is not useful and/or not required, I'm just saying VSC does work and works fairly easily by pointing git at a local SSH client.
  • I think this could possibly be achieved with an extension

Repeating myself, without both git/ssh internal to code, I have yet to determine a lesser option. I am absolutely willing to work on this , but it has to align with the goals of the team and get a blessing from @joaomoreno in particular.

@cleidigh I don't understand what the plan is.

@joaomoreno
I was hoping for more responses from other parties, but need your opinion/preference on possible plans.
Just to be clear, Code appears to work just fine for SSH private key access via git with just a bit of external configuration. Some here are suggesting greater integration and improved out-of-pocket experience.

Some possible approaches:

1- Implement git/ssh set up helper/Wizard - Find ssh, set GIT_SSH - internal addition
2- Same as 1 implemented as extension
3- Extend above to coordinate download of SSH/git for initial setup
4- Implement SSH client/tools - internal addition
5- Same as 4 implemented as extension
6- Implement git/SS H internally - similar to eclipse/egit

I think number 1 is sufficient (maybe 3) despite the fact it does not implement everything people are talking about. Options 4-6 seem like too much effort and a big change to key components.

Preferences @joaomoreno / all ?

It might be a good idea to try using VS Code with Git on Windows and identify the pain-points. For me, the main problem is authentication.

Option 1 is definitely my favourite.

@BeginnerForLife
If we had some helper/ssh discovery and set up does that help?
I did set up ssh for git for Windows, besides installing the client (I already had it) I just had set GIT_SSH
also added key fingerprint with agent.

Focusing on option one per @joaomoreno preference:

  • Detect workspace with repository using ssh , start helper
  • Provide command to start out helper anytime
  • Search for installed SSH, check environment variable is set
  • Warn user if no SSH found, suggest/point appropriate clients
  • offer to set an environment variable
  • prompt the user for private key to use and add fingerprint to agent

I believe but cannot promise all of the above it's practical. Assuming no one has any other brilliant idea
I think it would be good to basically prototype the above.

Additional feedback welcome.

Yeah, I think those bullet points should cover it. That last one in particular (prompt the user...) should solve a lot of people's problems.

@BeginnerForLife
Thanks. I am going to start with this approach and hopefully others will chime in with any other input.
I think I will post a pointer to my repository before I do a PR to see what people think. Check back here
to track my progress.

I agree that (1) is the best approach. And it's basically what I do at the moment - start ssh-agent if it's not already running and set the environment variables, then start VS-Code from that command line, so it picks up the environment variables.

If VS Code can check that SSH-Agent isn't already running and then start it if necessary, that would be great.

I use PowerShell's Git Module to do all of this - but it uses the logic from:
https://help.github.com/articles/working-with-ssh-key-passphrases/
So hopefully that will work, from a Node point of view (although presumably you'd need to check it works on all OSs)

@andrewducker cc: all

Update: I had to return to a previous PR but, I've actually made a great deal of progress on this:

  • Besides easy stuff like checking/setting GIT_SSH , checking git client, the key agent
  • Also found that it looks like the Windows key agents will allow key additions after startup
  • I think we can install new keys under Code launching the key agent which itself will prompt for a passphrase.
  • Next experiment is if I can detect a failed SSH login

Should be able to go back to this in a day or so.

Same here on macOS High Sierra with a default private key that's passphrase-protected. The passphrase is stored in the OS keychain during a logon session. When I reboot my mac, I have to re-enter it before the first git pull / git push for some extra security and the passphrase is no longer asked since then until I log off. Here is how the terminal behaves when I interact with a remote repo for the first time:

$ cd /path/to/repo
$ git pull
Enter passphrase for key '/Users/me/.ssh/id_rsa':
[me typing passphrase and pressing enter]
Updating 3e97c76..65a959c

However, when it is VSCode that's trying to pull something after a reboot, this error shows up:

screen shot 2018-02-12 at 11 05 09

The workaround is to open a terminal, navigate to the repo and type git pull. Not a disaster, but could be improved.

__UPD:__ Interestingly, when it comes to asking for a GPG key passphrase to sign new commits, VSCode works promptly and shows a popup window with an input field.

What’s the status on this?

Currently, the error Git: [email protected]: Permission denied (publickey). is shown.

Users who created a key pair in ~\.ssh can authenticate via the command line by entering the passphrase for the key pair but not from within VS Code.

@cleidigh any luck?
Does anyone have any idea how we can intercept the password request event? I figure once I have that intercepted I may have a chance at doing what atom does and providing a text box to use. But atm I'm lost for ideas.

I had all kinds of credential issues, until I realize that the problem is not with VSCode but with the environment. If you have properly configured ssh, git and so on, you won't have any problems, that's true for both Linux and Windows. And if something go wrong, you can always force it via the terminal.

I don't need to set up the environment for other IDEs.
In Eclipse, for instance, I can launch it directly, and when it needs to access a remote git repository it will ask me for the password to decrypt my SSH keys.
Visual Studio Code should do likewise.

All: Update
while I made quite a bit of progress on this, I had to put it aside for several reasons so I have not made much progress since January. sorry about that. I am hoping to get this going for May.

To @john681611 @andrewducker

As described earlier in the thread, the one fundamental issue that cannot be implemented "cleanly"
is prompting or any type of management of the keys. This is because Code relies on external GIT and
GIT relies on the systems SSH. Without Code implementing these internally (such as eclipse) we have limited options interacting with these external components.

My current prototype can do the following:

  • check if any repository uses SSH if so started configuration Wizard for below:
  • check and prompt for the environment variable GIT_SSH
  • check SSH client
  • force password dialog from client if possible (WIP) Note this prompt is the client 's not Code's

I agreed that it would be nice per @andrewducker to respond like Eclipse, but this would mean the team having to implement a significant piece of functionality already taking care of.

Note: Another approach might be if we could get the official GIT client to handle more security parameters we could use to control the SSH. That would keep the current architecture the same

All / Update

I've been working on the last and most important piece of the prototype: an askpass shim to allow Code to provide a native passphrase GUI prompt. Currently I believe this will be possible and in conjunction with the platform appropriate ssh-agent , credentials will be stored in their normal manner .

My problem is I cannot get either SSH or GIT to honor SSH_ASKPASS, GIT_ASKPASS or core.askpass under GIT Bash or CMD on Windows. the terminal prompt is the only thing that shows. As the most basic test I set one or all of these to the built-in git-gui--askpass but, this does not work either despite the program been executable if tested from the command line.

Has anyone utilized these methods to change the passphrase entry on Windows or any other relevant scenarios?

Sourcetree just pops up a terminal as well. It's not that bad.

To add to @ValentinH's solution on macOS 10.12 Sierra and later, just the UseKeychain directive fixes the issue on my machine (macOS 10.13.5 High Sierra Developer Beta, 17F70a). The AddKeysToAgent directive doesn't appear to be necessary. This configuration works for me:

Host github.com
  HostName github.com
  IdentityFile /path/to/your/ssh/private/key
  UseKeychain yes

What's the status on this?

'14581: VS Code requires git ssh keys to be named as "id_rsa"' was closed as a duplicate of this issue. Not sure I see how this is a duplicate - "Support git with private key password". These seem like separate issues.

EDIT: this was only a fix for the single instance of the terminal that I was running; even opening a new terminal in the same code session resulted in the public key error again

It looked like my ssh-agent had either died at some point or forgotten my non-"id_rsa" key that I use for git. So i just ran:

eval "$(ssh-agent -s)"
ssh-add path/to/my/github/ssh/private/key

and everything was back to normal. This is the sequence of commands that GitHub tells your to run when setting up a new SSH key anyways.

I'll admit I haven't read most of this thread, but for me this worked.

@cleidigh @joaomoreno this may not be a bug but rather improperly set up ssh keys, particularly in macOS. Sierra radically changed how keys are kept in session

i just solve it when i regenerate a new sshkey without the passphrase on it. i guess maybe vscode cannot open a shell to let u type passphrase in.

Just needed to add my key to the Mac keychain with ssh-add -K ~/.ssh/id_rsa ; replace id_rsa with your key if you're not using the default.

A workaround for Windows 10:

  1. Make Git use the OpenSSH that comes with Windows instead of the one that comes with Git.
    git config --global core.sshCommand "C:/Windows/System32/OpenSSH/ssh.exe"
  2. Set the ssh-agent service (not the one that comes with git) to run automatically.
    Open Task Manager, Services tab, click Open Services.
    Find OpenSSH Authentication Agent, open properties, set Startup Type to Automatic, hit OK.
    Also start the service or restart your computer.
  3. Add your password protected key to the agent.
    ssh-add
    It should automatically pick up keys stored in C:\Users\%USERNAME%\.ssh which is where ssh-keygen creates them.
    Enter your password(s) at the prompt.

Note: If, when installing Git for Windows, you selected the option to add bash commands to PATH, the ssh-add command might point to the wrong executable. If so, you can manually run the included one to get your key added to the agent:
C:\Windows\System32\OpenSSH\ssh-add.exe

Now the built-in OpenSSH auth agent will run on start up with your password protected key unlocked, and Git will use the Windows OpenSSH instead of it's own. So no need to type in your password every time, no need to manually start the ssh agent, and no need to start VS Code from command line.

Exactly as LynnScarlett noticed, there is no way to enter passphrase for the key and using keychain is unsafe, so will VSC add support for this basic feature?

I fail to see how Keychain is unsafe. Moreover, popular IDE’s do allow for password entering, so VSC could very much support both methods of entry

I meant ssh-agent I might be confusing two things, I'm not certain : )

Ssh-agent is only “insecure” in the sense that it loads the key per session. You have other problems if you have a compromised computer

This explains the insecurity of using ssh-agent in more detail:
http://rabexc.org/posts/pitfalls-of-ssh-agents
Cheers!

These all boil down to: don’t trust your machine to someone else who has root access - which you shouldn’t be doing anyway. So again: if ssh-agent is compromised due to the details in that article, you have bigger problems

@whatsyourgithub solution worked for me. But I guess it's not the best solution.

VS Code version: Code 1.27.2 (f46c4c4, 2018-09-12T16:17:45.060Z)
OS version: Windows_NT x64 10.0.17134
git version 2.19.0.windows.1

Still not working.

It's been two years now, and still no fix for this. The same issue applies to Atom, so I guess this is not something that's easily added? All I'd really want is Push (with passphrase) in the More Actions... git dropdown in the source control panel.

I'm happy to type in the passphrase on every push, I just don't want to have to go to the command line and type raw git commands.

It's been two years now, and still no fix for this. The same issue applies to Atom, so I guess this is not something that's easily added? All I'd really want is Push (with passphrase) in the More Actions... git dropdown in the source control panel.

I'm happy to type in the passphrase on every push, I just don't want to have to go to the command line and type raw git commands.

Try cloning the repo with https instead of ssh. That makes VS Code ask for username and password for me.

I just came from Atom to check Github Pull Request in VS Code and the first think is

Please make sure you have the correct access rights
and the repository exists.

git show :index.html
git pull --tags origin master
git show :index.html
[email protected]: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.

so I will not use the the option with only the ssh key without typing my password as well.
So I will come back to VS code and Github Pull Request extension later on.
I love what the community is done so far and I'm looking forward to be using this in the future with my security preference.

Try cloning the repo with https instead of ssh. That makes VS Code ask for username and password for me.

Thanks, that works for me too. And if you install Git for Windows credential manager and type the following command into the git bash shell in VS code:
git config --global credential.helper manager
Then synchronizing and pulls work without having to re-key the Gitlab user id and password.

It would be nice if one could do the same for SSH, given that's the Gitlab repo path default.

@whatsyourgithub , would like to use your solution (looks better than primitive and buggy "launch VSC via command prompt") but I am getting a VSC error message:
Git: no such identity: /C/Users/myuser/.ssh/myrsaKey_rsa
Even though the file is there.
And, another thing... while trying C:\Windows\System32\OpenSSHssh-add.exe, I also get the No such file or directory.
I am using the VSCode powershell to type these commands
Any ideas?

I switched to https rather than SSH. That's the only way I could get it to play nice. Interestingly, Github actually recommends using https rather than SSH.

@whatsyourgithub , would like to use your solution (looks better than primitive and buggy "launch VSC via command prompt") but I am getting a VSC error message:
Git: no such identity: /C/Users/myuser/.ssh/myrsaKey_rsa
Even though the file is there.
And, another thing... while trying C:\Windows\System32\OpenSSHssh-add.exe, I also get the No such file or directory.
I am using the VSCode powershell to type these commands
Any ideas?

I'd try opening Powershell outside of VS Code first, though it shouldn't matter.

OpenSSH is supposed to come installed with the latest versions of Windows 10. Try updating.
If that doesn't work, try going to Settings > Apps > Apps and Features > Manage optional features > Add a feature and look for OpenSSH.

@whatsyourgithub , would like to use your solution (looks better than primitive and buggy "launch VSC via command prompt") but I am getting a VSC error message:
Git: no such identity: /C/Users/myuser/.ssh/myrsaKey_rsa
Even though the file is there.
And, another thing... while trying C:\Windows\System32\OpenSSHssh-add.exe, I also get the No such file or directory.
I am using the VSCode powershell to type these commands
Any ideas?

I'd try opening Powershell outside of VS Code first, though it shouldn't matter.

OpenSSH is supposed to come installed with the latest versions of Windows 10. Try updating.
If that doesn't work, try going to Settings > Apps > Apps and Features > Manage optional features > Add a feature and look for OpenSSH.

Hi.
Thanks for replying.
OpenSSH (client) was already installed.
I repeated the procedure usng the standaone powershell but I keep getting the error message
no such identity: /C/Users/<user>/.ssh/RSAPRIVKEY_rsa: No such file or directory
WOUld this related to the ownership of the RSAPRIVKEY_rsa ? I did not issue the key using powershell but copied it from another place (anyhow, it works with Source tree or with the Git GUI)

@whatsyourgithub , would like to use your solution (looks better than primitive and buggy "launch VSC via command prompt") but I am getting a VSC error message:
Git: no such identity: /C/Users/myuser/.ssh/myrsaKey_rsa
Even though the file is there.
And, another thing... while trying C:\Windows\System32\OpenSSHssh-add.exe, I also get the No such file or directory.
I am using the VSCode powershell to type these commands
Any ideas?

I'd try opening Powershell outside of VS Code first, though it shouldn't matter.
OpenSSH is supposed to come installed with the latest versions of Windows 10. Try updating.
If that doesn't work, try going to Settings > Apps > Apps and Features > Manage optional features > Add a feature and look for OpenSSH.

Hi.
Thanks for replying.
OpenSSH (client) was already installed.
I repeated the procedure usng the standaone powershell but I keep getting the error message
no such identity: /C/Users/<user>/.ssh/RSAPRIVKEY_rsa: No such file or directory
WOUld this related to the ownership of the RSAPRIVKEY_rsa ? I did not issue the key using powershell but copied it from another place (anyhow, it works with Source tree or with the Git GUI)

OK. Solved it.. In the ./ssh/config file I had the path to the ssh key s C:\Users\.ssh\RSAKEY_rsa and changed it to ~/.ssh/RSAKEY_rsa
Then just had to register the key and that was all.
Thanks

@whatsyourgithub, sorry to disturb again. I am trying to help my colleague and he is not succeeding (doing as you suggested above works for me but not for him). These are the symptoms:
He is able to perform a git fetch from the PS console but when he pushes or syncs using gitacora (the plugin to automatically sync - that also I use without any issues) he gets the following error message:
Permission denied (publickey).
We know the key has been added by OpenSSH because C:\Windows\System32\OpenSSH\ssh-add.exe -L retrieves his public key and because if we use the command git fetch from PS, it works.
Any idea on how can help him diagnose / fix ?

@whatsyourgithub, sorry to disturb again. I am trying to help my colleague and he is not succeeding (doing as you suggested above works for me but not for him). These are the symptoms:
He is able to perform a git fetch from the PS console but when he pushes or syncs using gitacora (the plugin to automatically sync - that also I use without any issues) he gets the following error message:
Permission denied (publickey).
We know the key has been added by OpenSSH because C:\Windows\System32\OpenSSH\ssh-add.exe -L retrieves his public key and because if we use the command git fetch from PS, it works.
Any idea on how can help him diagnose / fix ?

Sounds like his key is not linked to his github account, or his github account is not added as a collaborator on the repo.

Sounds like his key is not linked to his github account, or his github account is not added as a collaborator on the repo.

I am managing the bitbucket server and I added his pub key there (and actually he is able to access fetch and push when he uses the command line via PowerShell).
Or is it something i dd not catch from your answer?

Just needed to add my key to the Mac keychain with ssh-add -K ~/.ssh/id_rsa ; replace id_rsa with your key if you're not using the default.

macOS High Sierra vs code
[email protected]: Permission denied (publickey).
fatal: Could not read from remote repository.

Tagging this because this fixed the issue with integrated git not working within vscode even though it worked perfectly fine from the command line.

@whatsyourgithub It seems work via git config --global core.sshCommand "C:/Windows/System32/OpenSSH/ssh.exe" after I generate a new id_rsa.

  1. But the key has a password, when I push there is no prompt windows dialog to let me input my password.
  2. If I use a key that had exit on my PC via ssh-add .ssh\id_rsa,there is error. Why can't I add the key? I want to use the one same key that I had add before.
@         WARNING: UNPROTECTED PRIVATE KEY FILE!          @
Permissions for 'D:/ablob/.ssh/id_rsa' are too open.
It is required that your private key files are NOT accessible by others.
This private key will be ignored.
Load key "D:/ablob/.ssh/id_rsa": bad permissions
[email protected]: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

OS: Windows 10
VSC: 1.28

Any updates?

Any plans to handle this in the near future?

According to VS Code documentation (https://code.visualstudio.com/docs/editor/versioncontrol):

Can I use SSH Git authentication with VS Code?
Yes, though VS Code works most easily with SSH keys without a passphrase. If you have a SSH key with a passphrase, you'll need to launch VS Code from a Git Bash prompt to inherit its SSH environment.

This page was dated 12/12/2018.

So I just generated new ssh keys without a passphrase (by leaving it empty when prompted and overwriting the previous ones), added them to my account on GH and also added the identity to the ssh-agent by running ssh-add.exe ~\.ssh\id_rsa. Now, everything works.

If others can confirm this, I would suggest closing this topic since official VS Code documentation already explicitly states that it will only work with passphrases by launching VS Code from git-bash.

If others can confirm this, I would suggest closing this topic since official VS Code documentation already explicitly states that it will only work with passphrases by launching VS Code from git-bash.

Well, the documentation says "most easily", not that it wouldn't work at all when keys have passphrases, and its suggestion of launching VS Code from a Git Bash prompt is only required for those who are using Git-for-Windows' SSH agent to manage their keys.

I can actually confirm that I use Windows' SSH agent (not the one that comes with Git for Windows), load my (password-protected) SSH key into it, and then launch VS Code normally (not from any specific command prompt) and I can git push/pull successfully to repos that require my key.

I confirm that opening VS Code via git bash will ask ssh key and in VS code will ask for your ssh passphrases in the terminal.

I had similar issue with VSCode on Windows 10 not pushing/pulling from _ssh://repo_ while it was possible in the terminal.

I am using CMDer with git-for-windows and VSCode was configured with git.path pointing to these binaries. I also have ssh config file in _%USERPROFILE%\.ssh_ directory with all the necessary options and Identity file set to public key file. KeePass with KeeAgent are serving the keys.

Previously mentioned procedure to first run terminal (CMDer) and then run Code from it works fine but I did not like it. So I tried (successfully) another approach:
In the git.exe directory I have created the cmd file:

@echo off
set SSH_AUTH_SOCK=/path/to/my/sock.file
%~dp0git.exe %1 %2 %3 %4 %5 %6 %7 %8 %9

(SSH_AUTH_SOCK path needs to have forward slashes) and pointed git.path option in Code to it.

Now Code starts, seems to read the _~/.ssh/config_ file without any additional "hacks", and is able to use the agent.

Edit:
I guess, setting the SSH_AUTH_SOCK environment variable globally would help too - with the cost of the keys being accessible by every application...

"you'll need to launch VS Code from a Git Bash prompt to inherit its SSH environment."

One of the most mediocre things I have heard from Microsoft; I shouldn't have to start VS Code from a specific command line to make ssh work; maybe try to implement a proper solution.

backlog? really?

This issued caused me to switch to powershell and posh-git which works reasonably well. For the ssh-agent to work seamlessly I had to add the following to $profile.CurrentUserAllHosts (defaults to C:\Users\USERNAME\Documents\WindowsPowerShell\profile.ps1).

Import-Module posh-git
Set-Alias ssh-agent "$env:ProgramFiles\git\usr\bin\ssh-agent.exe"
Set-Alias ssh-add "$env:ProgramFiles\git\usr\bin\ssh-add.exe"
Set-Alias ssh "$env:ProgramFiles\git\usr\bin\ssh.exe"
Start-SshAgent -Quiet

If others can confirm this, I would suggest closing this topic since official VS Code documentation already explicitly states that it will only work with passphrases by launching VS Code from git-bash.

I have to disagree here: this issue is about the lack of proper SSH passphrase support in VS Code, and the documented workaround is simply that - a workaround. There are already too many temptations for the lazy user to skip good passphrase security, so any modern tool should make it easy to Do The Right Thing.

Based on what others have suggested above, I just created a bash script file (ie. projectName.sh) and I wrote the following in it:
"location/to/Code.exe" "location/to/project"

Now all I have to do is double click on the file to get VSCode opened and working with a certificate with a passphrase.

BTW: In case it helps others stumbling across this issue, I also had to: git config --global http.sslBackend schannel as described here.

I'm perplexed that, after two long years, a thing as basic as "work with git using ssh using a key that HAS a passphrase" has not been addressed yet wothout using ugly-looking workarounds. VSCode is a great editor IMHO, but this "feature" is really needed. Please prioritize it

Here's an old post I threw on stackoverflow which may be helpful; one option is using the Windows Credential Manger: https://stackoverflow.com/questions/35110079/git-bash-pageant-not-using-keys/43313491#43313491

I guess the question is whether or not VSCode should be in charge of handling SSH/HTTPS credentials as a keystore manager. It kind of seems like this should be handled by the OS, a 3rd party program, or a proper configuration of git which mixes in with the first two points.

As much as I like the sound of this feature it already seems like Unix and Windows should have ways of handling this problem without adding this into VSCode.

Not sure if anything here in these github articles helps either: https://help.github.com/articles/connecting-to-github-with-ssh/
Ultimately sounds like they're telling you to use bash on windows / another bash windows alternative, which then gets people back to this same issue with a hacky workaround : \

@ctsstc Yes, I have installed the Git Credentials Manager for Windows, but for some reason, it's not working. I'm aware that this may not be a responsability for VSCode . For example, in Android Studio and IDEA-based IDEs, they only care to call the git binary, and the only integration they have is when the operation requires a passphrase, the IDE persists it securelly and passes it to Git - perhaps this is a good approach. Maybe this is the only thing they are missing?

@ctsstc Strongly disagree, you can't implement an user interface to a CLI program -meaning GIT in this case- and then claim that when the program needs input is no longer your problem; if you didn't want people to rely on VC to use git then you shouln't have integrated git from the start, don't half-ass software specially if its supposed to be backed up by Microsoft, and specially don't half-ass decades-old security best practices such as SSH keys with passphrases.

I guess a significant point here is that Atom will remember SSH passphrases for git repos. Surely vscode can do the same since they're both based on the same editing engine?

I guess the question is whether or not VSCode should be in charge of handling SSH/HTTPS credentials as a keystore manager.

I don't believe it should, but I also don't believe that's what's being asked for here. As @Ivanca pointed out, VSC has chosen to present a UI over top of git, so the question is how much git functionality should be exposed through that UI. I wouldn't expect every obscure git operation to be available through VSC, but pull/push are fundamental - I don't think VSC can claim to fully support them without providing UI glue to the underlying passphrase challenge.

So the expected outcome is to have it prompt for the password. I think that's a reasonable ask/feature.

Rather than showing:

Permission denied, please try again.
Permission denied (publickey,password).

I feel like I've seen this functionality recently on Mac a couple days ago, but maybe it's not implemented on Windows, or maybe it was asking for my system password to access the system keystore.

Edit, just tried this on Mac:

image

So it looks like this is supported on Mac but not Windows (I'm assuming this problem still exists), so the feature is to have parity between the two OS.

Any updates on this? It's been 2 years since this issue was reported and still can't get VSCode to work with Git SSH:
image

@ctsstc I can confirm it does work in Mac in the terminal tab. What is lacking is it prompting for a passphrase when using the pull/push fetch functions from the GUI. It just ignores the fact you have a passphrase on your key and submits a null/nil password causing the git operation to fail.

I firmly think this should be addressed, regardless if VSC decides to cache passphrase credentials. Don't fail when there's a passphrase on the rsa key, prompt for the key.

when is this going to happen?

Is this going to be fixed? Same problem on windows

Doesn't look hopeful. I gave up and switched from SSH to https.

My current work-around: I usually have a terminal open in VSCode anyway (using it to interact with npm, etc.), so I just do my git push from there. It's not how it _should_ work, but it does at least prompt me for my password.

On macOS, I added this to my ~/.ssh/config at the very end (which is important, don't put anything below):

Host *
   AddKeysToAgent yes
   UseKeychain yes 

Then I did a git pull so macOS would ask for my ssh password. After that, macOS is never asking me again for the password, therefore VSCode's version control is working as it should.

Hope it helps someone.
Cheers!

Other workarounds :

  • Use plink from putty instead ssh as git ssh commad, then use pageant to load keys
  • Use git over http/https instead git over ssh

Has anyone tried either of these on Windows?

https://github.com/PowerShell/openssh-portable

I use win32-openssh, like above, workaround by pushing git from terminal. The lack of ssh:// paths being recognized is an issue I already filed that is related to this. My main use case is using the sshfs extension which git and other extensions like python don't work with because they don't know how to interpret ssh://

Is there any plan to support this?

This is still an issues. The workarounds are not an option for everyone; e.g. my machine can (potentially) be accessed by others and therefore I will not unlock my key. In my case git on the command line simply asks for the password, I'd say VS Code should do the same in a popup.

Actually kind of shocked this isn't a feature after 2 year, still wondering why this hasn't been picked up and prioritized.

Currently using VSC version 1.34.0
qwe
and the issue has not been fixed.

Still having this issue here as well, on Windows 10. I got rid of Putty now that OpenSSH is included in Windows 10, but VS Code doesn't seem to respect it? I have to manually push and pull through the terminal in VSCode, which works fine, but I loved being able to just click a button to sync.

@arcs- This is unlikely to be fixed given that git doesn't provide a way to interact with the SSH key child process. If your machine is accessible by others then lock it when you're away from your desk. Otherwise you can start up ssh-agent in either macOS or Windows to work around this issue as described here: https://help.github.com/en/articles/working-with-ssh-key-passphrases

@flaw600 This process only seems to help if I launch code from the same git-bash window where the ssh-agent has been initialised, which is a bit clunky and prevents the use of right click extensions on explorer being much use.

The fact it's over 3 years on and this link is still applicable seems unfortunate.
https://nathan.alner.net/2015/08/24/vs-code-ide-with-passphrased-git-ssh-keys/

Opening code via the start menu it ignores the ssh-agent and fails to pull/push.

Any suggestions? It's quite a big painpoint for doing development right now vs other platforms.

Using https has been the superior solution for some time. Its every bit as secure, if not more so, as you can create specific tokens for access. Windows SCM credential manager takes care of everything automatically.

As a bonus, I am pretty sure HTTPS is actually faster than SSH.

@gdamore: Any evidence references to support your claim that HTTPS is
faster than SSH?

On Mon, 17 Jun 2019 at 11:45, gdamore notifications@github.com wrote:

Using https has been the superior solution for some time. Its every bit as
secure, if not more so, as you can create specific tokens for access.
Windows SCM credential manager takes care of everything automatically.

As a bonus, I am pretty sure HTTPS is actually faster than SSH.


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/microsoft/vscode/issues/13680?email_source=notifications&email_token=AFLBAENFUKYEOE3WLKBGCJLP265Q7A5CNFSM4CSXV3P2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODX3YNJI#issuecomment-502761125,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AFLBAEOC5BVCGGJ7EDXTINTP265Q7ANCNFSM4CSXV3PQ
.

Not specifically with git, but in other uses (large file copies), we've seen that. I think it really relates to things set at the TCP layer where SSH seems to have values that are more appropriate for interactive use, whereas HTTP tends to be more optimized for actually moving files, which is really what git is doing in this case.

I hate saying this, but it magically started working for me. Not sure if it was starting SSH through Powershell, or CMD -- I have no idea! Just a bunch of trying and then it magically worked.

On Windows you can use pageant as your SSH agent and then set env variable GIT_SSH to plink. Both these tools are part of PuTTY and also bundled with TortoiseGit.

Does me no good on a mac

On Wed, Jul 3, 2019, 11:44 AM Justin notifications@github.com wrote:

On Windows you can use pageant as your SSH agent and then set env
variable GIT_SSH to plink. Both these tools are part of PuTTY and also
bundled with TortoiseGit.


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/microsoft/vscode/issues/13680?email_source=notifications&email_token=AFBZHXFVMRQ4DBPV2TLBBGTP5TJN7A5CNFSM4CSXV3P2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZFAWSQ#issuecomment-508169034,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AFBZHXD63DGD5FUXRJYMLXDP5TJN7ANCNFSM4CSXV3PQ
.

Why is this still a thing?

wow, so after 3 year is still not possible to connect VS code via ssh, at least to start it from command line

Well, I didn't get over the passphrase as I haven't set it, but somehow I was able to let VSCode at least set to use ssh once opened as a root( or by Windows as admin). This is after I installed Openssh or in Windows have set up the connection with Putty. After I check the configuration of the ssh and installed, as instruction here https://help.github.com/en/articles/testing-your-ssh-connection . Please refer to this as well as, it does give many useful insights as every case depend on how you have set your ssh agent and the OS( I am running Ubuntu 18.04) https://help.github.com/en/articles/error-permission-denied-publickey

Using version 1.36.1, still can't connect to Github via SSH with a passphrase - had to take the passphrase off my key. What's so difficult? With HTTPS you ask for git user and password... (multiple times, which is why I don't want to use it).

This is kind of annoying. Using a password with your SSH key promotes good security. It's technically a form of 2FA (what you have: the key + what you know: the password). I'm using this editor on MacOS & it's really annoying to hop into the console for all git operations. VS Git UI just fail. It should pop a password input

On macOS, I added this to my ~/.ssh/config at the very end (which is important, don't put anything below):

Host *
   AddKeysToAgent yes
   UseKeychain yes 

Then I did a git pull so macOS would ask for my ssh password. After that, macOS is never asking me again for the password, therefore VSCode's version control is working as it should.

Hope it helps someone.
Cheers!

The above works for me. Perhaps a note could go in here: https://code.visualstudio.com/docs/setup/mac

This would be great to get either a resolution or a proper work-around on Windows.

The “proper work-around” is to use HTTPS URLs instead of SSH, along with the git-scm credential manager. Works perfect for me.

Sent from Mail for Windows 10

From: Kai Richardson
Sent: Wednesday, August 28, 2019 9:33 AM
To: microsoft/vscode
Cc: gdamore; Mention
Subject: Re: [microsoft/vscode] Support git with private key password (#13680)

This would be great to get either a resolution or a proper work-around on Windows.

You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.

@gdamore that is not the correct workaround. This issue is specifically for using SSH protocol. Some people may be using a Git server where the admins specifically don't allow http(s) Git operations so telling them to use https offers no solution to them.

@Kai-Richardson It does work on Windows if you configure Git to use an SSH command that supports an SSH agent and open the key in that agent.

  1. TortoiseGit: Set env variable GIT_SSH to the TortoiseGitPlink.exe in your TortoiseGit install folder, convert private keys to PPK format with the included puttygen.exe and then open the private keys in pageant.exe. You could plain PuTTY instead of TortoiseGit, in that case set GIT_SSH to the plink.exe and use puttygen/pageant.
  2. Install the official MS OpenSSH (link, I use chocolatey with the SSH Agent Feature enabled), start the ssh-agent service, open private key with ssh-add <path to key file>, and set env variable GIT_SSH to the ssh.exe (usually C:\Program Files\OpenSSH-Win64\ssh.exe). My only issue here is after the 8.0 release it seems to have problems reading private keys with the traditional (-----BEGIN RSA PRIVATE KEY----- format, favoring instead the -----BEGIN OPENSSH PRIVATE KEY----- format).

Updated my visual studio code, can no longer interact with my github through the application. Version 1.37.1

OS: Windows 10 Pro: version: 10.0.17134 Build 17134

Does the MS team just hate SSH?

Which IDE actually supports SSH passcodes? Because Jetbrains’s products don’t either. So you have 2 of the top 3 vendors not supporting SSH passcodes natively (and the other - Github - I just don’t know if their Atom editor supports SSH passcodes natively).

On Aug 29, 2019, at 8:43 PM, Chris Migut notifications@github.com wrote:

Updated by visual studio code, can no longer interact with my github through the application. Version 1.37.1

Does the MS team just hate SSH?


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub https://github.com/microsoft/vscode/issues/13680?email_source=notifications&email_token=ACKS4GSGFBF2OGBCXPN55LDQHB3NLA5CNFSM4CSXV3P2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD5QI7ZA#issuecomment-526421988, or mute the thread https://github.com/notifications/unsubscribe-auth/ACKS4GTHNDBY5DETIRNVX6TQHB3NLANCNFSM4CSXV3PQ.

Did I did any error? I just boot up Kali Linux as a double boot on Windows

  1. Everything went well and perfect after a long process but somehow the
    device connected to git being attached and tag together and when I try to
    get the path. Booommmmm so many files being pulled to my hard drive... What
    is happening ????

PrinceKK301088

On Sat, 31 Aug 2019, 8:59 am flaw600, notifications@github.com wrote:

Which IDE actually supports SSH passcodes? Because Jetbrains’s products
don’t either. So you have 2 of the top 3 vendors not supporting SSH
passcodes natively (and the other - Github - I just don’t know if their
Atom editor supports SSH passcodes natively).

On Aug 29, 2019, at 8:43 PM, Chris Migut notifications@github.com
wrote:

Updated by visual studio code, can no longer interact with my github
through the application. Version 1.37.1

Does the MS team just hate SSH?


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub <
https://github.com/microsoft/vscode/issues/13680?email_source=notifications&email_token=ACKS4GSGFBF2OGBCXPN55LDQHB3NLA5CNFSM4CSXV3P2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD5QI7ZA#issuecomment-526421988>,
or mute the thread <
https://github.com/notifications/unsubscribe-auth/ACKS4GTHNDBY5DETIRNVX6TQHB3NLANCNFSM4CSXV3PQ
.


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/microsoft/vscode/issues/13680?email_source=notifications&email_token=AH4ENDPM4O6N2MT3BFLXGRTQHG66NA5CNFSM4CSXV3P2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD5TCASY#issuecomment-526786635,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AH4ENDORTBRU3GTGOWJFOVLQHG66NANCNFSM4CSXV3PQ
.

Which IDE actually supports SSH passcodes? Because Jetbrains’s products don’t either. So you have 2 of the top 3 vendors not supporting SSH passcodes natively (and the other - Github - I just don’t know if their Atom editor supports SSH passcodes natively).

There is a duplicate thread about the same issue, someone said that Atom does support SSH key passcodes natively: https://puu.sh/B7qHY/57f3c89f47.png

The link is key protected

Sent from my iPhone

On Sep 16, 2019, at 1:32 PM, vitasam notifications@github.com wrote:

Which IDE actually supports SSH passcodes? Because Jetbrains’s products don’t either. So you have 2 of the top 3 vendors not supporting SSH passcodes natively (and the other - Github - I just don’t know if their Atom editor supports SSH passcodes natively).

On Aug 29, 2019, at 8:43 PM, Chris Migut @.*> wrote: Updated by visual studio code, can no longer interact with my github through the application. Version 1.37.1 Does the MS team just hate SSH? — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub <#13680?email_source=notifications&email_token=ACKS4GSGFBF2OGBCXPN55LDQHB3NLA5CNFSM4CSXV3P2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD5QI7ZA#issuecomment-526421988>, or mute the thread https://github.com/notifications/unsubscribe-auth/ACKS4GTHNDBY5DETIRNVX6TQHB3NLANCNFSM4CSXV3PQ.

There is a duplicate thread about the same issue, someone said that the Atom does support SSH key natively: https://puu.sh/B7qHY/57f3c89f47.png


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.

Interesting, I can open the link. The dialog from Atom:
atom_ssh_key_pass

apart from adding the ssh config entries above

if windows

Set-Service ssh-agent -StartupType Automatic 

in powershell
now the vs code should not prompt...

apart from adding the ssh config entries above

if windows

Set-Service ssh-agent -StartupType Automatic 

in powershell
now the vs code should not prompt...

I'm getting some permission error with this attempt. Any suggestions?

Set-Service : Service 'OpenSSH Authentication Agent (ssh-agent)' cannot be configured due to the following error: Access is denied
At line:1 char:1
+Set-Service ssh-agent -StartupType Automatic
+~~~~~~~~~~~~
+CategoryInfo : PermissionDenied: (System.ServiceProcess.ServiceController:ServiceController) [Set-Service], ServiceCommandException
+FullyQualifiedErrorId : CouldNotSetService,Microsoft.PowerShell.Commands.SetServiceCommand

I'm getting some permission error with this attempt. Any suggestions?

@seantma: PowerShell needs to be run as Administrator to have the needed Permissions.

apart from adding the ssh config entries above
if windows
Set-Service ssh-agent -StartupType Automatic

in powershell
now the vs code should not prompt...

It did not help in my case, VCode returns following errors, when I was trying to sync local commit with origin (remote):

fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

It looks like VCode does not use global GIT config (name and email), could it be?

Did this and it works (not tested with a ssh key with passphrase) :

  • Open a new terminal inside Visual Code, choose current project folder if prompted
  • VS will open a terminal with Poweshell
  • Run ssh-keygen.exe -> Enter, enter, enter..... -> key created in .ssh in user's folder (normallly in C:\Users\)
  • Copy the content of the key (.ssh/id_rsa.pub) and add to new key on Github settings

That's it

This is no proper solution, @leductan-nguyen. Not only is this issue specifically about password-protected keys, but also it just won't work if you gotta have multiple keys (I have one for GitHub and another for GitLab for example).

Any progress with this one?

@Badbreaddead, several solutions or workarounds have been posted above. It depends on the OS you are using:

OS X

Follow @dschu-lab's solution and add

Host *
   AddKeysToAgent yes
   UseKeychain yes 

to the _very end_ of ~/.ssh/config. If your ssh key does not have a standard name, you may also need to specify it with IdentityFile /path/to/your/ssh/private/key as others pointed out.
You'll then be prompted to add your passphrase the very first time you use it and it will then be stored in the Keychain for any subsequent uses.

Linux

Install keychain, e.g. via sudo apt install keychain, as @Silentz0r pointed out above. He then executes keychain --eval <ssh-key-name>, but it seems that keychain <path-to-ssh-key> has the same effect. Adding either to your .bashrc or equivalent should do the trick.

Windows

@geordanr's workaround is the only one that worked for me. Execute the following commands in Git Bash to add the ssh key to the agent and run code in the same session:

$ eval `ssh-agent`
$ ssh-add /path/to/key
$ code

If you want to save yourself having to type the first two commands every time, you can also add something like

#use fix path for SSH_AUTH_SOCK so it works more then one instance of gitbash
export SSH_AUTH_SOCK="$TEMP/ssh_agent_socket"

ps | grep ssh-agent > /dev/null
RUNNING=$?;

if [ "$RUNNING" -eq "1" ] 
then
# ssh-agent is not yet running
    eval `ssh-agent -a $SSH_AUTH_SOCK`
fi
ssh-add 

to your ~/.bashrc file in Git Bash to start the ssh-agent automatically (taken from here and adjusted slightly). If your key does not have a standard name, you'll need to specify the path to it after ssh-add, e.g. ssh-add ~/.ssh/id_rsa_personal_key.

Which IDE actually supports SSH passcodes? Because Jetbrains’s products don’t either. So you have 2 of the top 3 vendors not supporting SSH passcodes natively (and the other - Github - I just don’t know if their Atom editor supports SSH passcodes natively).

On Aug 29, 2019, at 8:43 PM, Chris Migut @.*> wrote: Updated by visual studio code, can no longer interact with my github through the application. Version 1.37.1 Does the MS team just hate SSH? — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub <#13680?email_source=notifications&email_token=ACKS4GSGFBF2OGBCXPN55LDQHB3NLA5CNFSM4CSXV3P2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD5QI7ZA#issuecomment-526421988>, or mute the thread https://github.com/notifications/unsubscribe-auth/ACKS4GTHNDBY5DETIRNVX6TQHB3NLANCNFSM4CSXV3PQ.

PyCharm supports my ssh key with passphrase with no problem, it asked me for the passphrase once and never again and all git functionality works as expected.

Execute the following commands in Git Bash to add the ssh key to the agent and run code in the same session:

$ eval ssh-agent
$ ssh-add /path/to/key
$ code

For what it's worth, this works on Linux just as well - and there's no need to launch code via the terminal. The shortcut will do fine too. The terminal itself can be closed right after these commands.

I know of at least another workaround:

Install ssh-askpass (on Arch Linux this is provided by both the x11-ssh-askpass and also the seahorse packages, and the binaries reside in /usr/lib/ssh/ssh-askpass and /usr/lib/seahorse/ssh-askpass respectively). Installing one of these packages is all that's needed. VS Code will launch the password dialog every time it's required.

Just add those keys bellow to your environment:

DISPLAY=needs-to-be-defined
SSH_ASKPASS=/mingw64/libexec/git-core/git-gui--askpass

I could have sworn this was in the January 2020 milestone. 😕

Adding on to this https://github.com/microsoft/vscode/issues/13680#issuecomment-559013132

Is that since bash prompts you on every login to key in your passphrase, you can chain running VSCode in a shortcut through bash. For the icon, just use the one that came with VSCode, likely under %LOCALAPPDATA%\Programs\Microsoft VS CodeCode.exe

If you already have ssh-agent running, this will launch code immediately. If not, it'll wait for you to enter your passphrase.

image

I would love to help with this. It's one of the few things I still wish that VSCode did, but even without it, doesn't matter, I still really enjoy using VSCode, so thanks!

Did you know that Git-for-Windows comes with a script called start-ssh-agent, it's in the cmd folder, which is typically added to the user's path on a standard install of Git-for-Windows. Maybe there's someway to use this to resolve this issue?

I'm wondering if someone can point me to chain of events that occurs when you click the push/pull button, maybe we can try to execute this script, possibly in the vscode terminal, or in a popup.

Also, as an added plus, if the user has already started ssh-agent, the script will usually find it, and just use the existing agent, so a passphrase isn't even required.

Thanks!

https://github.com/microsoft/vscode/issues/13680#issuecomment-525861890 also worked for me, but it's not very straightforward, and complicates things if you're also using Git for Windows git and bash.

What I found about the problem and a summary of the possible solutions

The main problem in Windows + Git for Windows (GfW) + VSCode + SSH git repo is this:

  • If you didn't launch either the Windows or GfW ssh-agent before (or don't have a helper/service doing it), it doesn't seem to be able to launch ssh-agent and ssh-add. Maybe it is not VSCode's responsibility, but it's nice to know or be prompted that ssh is not running.
  • If you did launch the GfW ssh-agent through a .bashrc, and if you launch VSCode from the Start Menu/Shortcut and not the same session (like running code from the cli), then VSCode doesn't get access to the GfW ssh-agent as well.
  • If you did launch the Windows version of ssh-agent, and have GfW installed, the GfW git does not use the Windows version of ssh-agent by default, since it also comes with its own version of ssh tools. VSCode seems to use the GfW git when available, so that may be why it doesn't detect that Windows ssh-agent is already running (with added keys) and use that.

Solution 2 is nice, but it's also not super straightfoward, these are the steps I took:

  1. Install OpenSSH Client under Optional Features
  2. Add GIT_SSH in Environment Variables, pointing to the OpenSSH Client tools, likely C:\Windows\System32\OpenSSHssh.exe
  3. Switch the Open SSH agent under Services to Automatic (if it is Disabled, mine was)
  4. Run ssh-add in PowerShell and you should see your key added
  5. VSCode should now be able to do git stuff with the SSH repo
  6. However, GfW git and bash does not use this agent (I tried pointing the bash env GIT_SSH to the Windows OpenSSH tools but they refuse to work together), and so you have to use the .bashrc script to start the agent and enter the passphrase another time when starting GfW bash.

For now, I'm sticking to Solution 1, since I also use Mac and Linux systems and it's nice having the same bash/git/ssh tools everywhere.

I tried chaining together the Git-for-Windows script called start-ssh-agent.cmd in the cmd folder, with Code.exe in the shortcut as %COMSPEC% /C %LOCALAPPDATA%\Programs\Git\cmd\start-ssh-agent.cmd && "%LOCALAPPDATA%\Programs\Microsoft VS Code\Code.exe" and it works, but it has this odd side effect of opening a second instance of VSCode after exiting the first instance, but I don't know why.

If I execute this line from the Windows terminal (with or without the preceeding %COMSPEC% /C) it works just fine.

Another thing I tried was to create a *.bat or *.cmd file with the same command as the shortcut, but I was surprised that it didn't work. VSCode starts, but can't pull/push, and responds with the dreaded "permission denied (publickey)." error.

I also spent some time hunting through the Git extension codebase but I couldn't figure out where to insert the ssh-start-agent script, ideally when it's looking for the version of Git and finds it's on Windows, like around lines 61-148 in git.ts since it runs git --version it could also run cp.exec('start-ssh-agent.cmd') but it'd have to have a way to get the passphrase from the user.

Finally, what I settled on was copying start-ssh-agent.cmd into a new file called vscode-ssh-agent.cmd and replacing the last line where it calls CMD with @call "%LOCALAPPDATA%\Programs\Microsoft VS Code\Code.exe". I can double click this and it works, and if I make it the target of a shortcut, then voila, it also works. But I can't pin it to the taskbar.

I am currently trying to implement this feature. It is still a work in progress, but I should have a PR available soon.

For now I start a ssh-agent, add the user key if git.sshPrivateKeyPath is set, prompt the user for his SSH key password if requested, and use the agent's environment variables for every git call.
My first tests on a Windows machine seem to work.

I read all the comments here but might have forgotten something, so please feel free to make any remark.

Adding to https://github.com/microsoft/vscode/issues/13680#issuecomment-583599355 from @weiliddat; I myself frequently use the "Open with VSCode" context menu (right click on folder) entry and I used ContextEdit to edit a context menu entry when opening folders with VSCode to launch it via Git Bash, so VSCode has access to the SSH context.

  1. Install ContextEdit.
  2. Run ContextEdit as administrator
  3. Find "File Folder" in the long list of extensions.
    image
  4. Double click on the "Open w&th Code" entry under "Shell commands"
  5. Change the "Command line" string to "C:\Program Files\Git\bin\bash.exe" -l -c "code '%V';exit". Be sure that "C:\Program Files\Git\" corresponds to your Git for Windows installation directory. You might want to copy the old command in case you need to reset.
  6. Click "OK" and "Exit"

Now, if you right click on a folder to "Open with VSCode" this should first launch Git Bash, and afterwards open VSCode in the right folder. If you've correctly set up Git Bash to launch your SSH Agent before starting Git Bash, this should prompt you to type the passphrase once every time you restart your computer. On subsequent opening this should directly open VSCode and have your SSH key all set up.

I wasn't able to find the ContextEdit entry when right clicking inside a folder in Explorer, instead of directly right clicking the folder itself.

This solution works like a charm.

Just add those keys bellow to your environment:

DISPLAY=needs-to-be-defined
SSH_ASKPASS=/mingw64/libexec/git-core/git-gui--askpass

Just add those keys bellow to your environment:

DISPLAY=needs-to-be-defined
SSH_ASKPASS=/mingw64/libexec/git-core/git-gui--askpass

https://github.com/microsoft/vscode/issues/13680#issuecomment-575204695
This solves it! Thank you very much!

Please, check this section. In short, it says that you need to start VSCode from GitBash or such to have required environment variables. Also, if you'd checked these variables in GitBash you might get something like this:
.

For example, if you want to not use GitBash to start VSCode every time(because this nonsense! IMHO), it's possible to add these using Environment Variables window or using a command rundll32.exe sysdm.cpl,EditEnvironmentVariables(i.e. through cmd.exe).

In the result it might look like that:

Now, just restart(not reload) VSCode and it should work:

Funny thing that it works even if DISPLAY=WTHeck, so, it might look for this variable's existence only.

Why not just simply define these(private key file path or SSH_ASKPASS) as a JSON config value somewhere as a workaround, so the VSCode would appended these at startup to its internal environment variables?

I'm not very familiar with how electron or windows applications work but would it be possible to develop a wrapper around this solution so when VSCode installs it would auto configure these settings.

TBH to me this doesn't seem like this would be all that difficult of a problem to solve but considering how this discussion has continued for 4 years it's probably a beast of an issue. It would be cool to see VSCode implement at least something so that users could use this pretty standard git feature without having to do their own workarounds. Though I see a point to be made in implementing it correctly the first time.

Thank you soufiene-slimi for your workaround solution and thanks F8ER for the clarification. Though there is a UI inconsistency, it at least works

Just add those keys bellow to your environment:

DISPLAY=needs-to-be-defined
SSH_ASKPASS=/mingw64/libexec/git-core/git-gui--askpass

Anything new here? I just began working with VSCode on WSL 2 and Git. And because VSCode frozes everytime I tried to push or publish something, I tried it on the terminal and it worked great because there I had the possibility to enter my passphrase.

This issue is so old and has a lot of comments. Maybe somewhere is a nice workaround without removing the passphrase from my key, and without saving the key somewhere in the configurations.

Hey guys,

I ran into this issue on my Mac as well.
I have a RSA key set up and my config looks like this

# GitLab.com
Host gitlab.com
  Preferredauthentications publickey
  UseKeychain yes
  AddKeysToAgent yes
  IdentityFile ~/.ssh/id_rsa

The thing is from VS code terminal when I push to the origin with CLI it successfully pushes my code with a prompt to enter a password.
The problem arises when I use the VScode GUI pull/push/sync it gives me

Please make sure you have the correct access rights
and the repository exists.
> git push -u origin v1.5_Testing
[email protected]: Permission denied (publickey).
fatal: Could not read from remote repository.

the only difference is the GUI does not prompt for a password which is why I am assuming its failing.

[email protected]: Permission denied (publickey).
...
the only difference is the GUI does not prompt for a password which is why I am assuming its failing.

@mohammedpatla Please, check this this.

That solution with environment variables does not help me. I do not have git installed on Windows but on Ubuntu 20.04 running on WSL2. There is nowhere a directory named mingw64 or a binary named git-gui--askpass anywhere.

Therefore I also think the solution is not working on a Mac either, @F8ER .

I cant run VScode through git-bash on a Mac @F8ER

That solution with environment variables does not help me. I do not have git installed on Windows but on Ubuntu 20.04 running on WSL2. There is nowhere a directory named mingw64 or a binary named git-gui--askpass anywhere.

I cant run VScode through git-bash on a Mac

Do you know what is Environment Variable?
@NicolasGoeddel You might like to check this link from ubuntu.com.
@mohammedpatla You might like to check this link from apple.com instead.

Also. please, try Google first. For example, an absence of git-gui--askpass might mean that there's no package git-gui installed, thus, you might need it installed.

That solution with environment variables does not help me. I do not have git installed on Windows but on Ubuntu 20.04 running on WSL2. There is nowhere a directory named mingw64 or a binary named git-gui--askpass anywhere.

I cant run VScode through git-bash on a Mac

Do you know what is Environment Variable?
@NicolasGoeddel You might like to check this link from ubuntu.com.
@mohammedpatla You might like to check this link from apple.com instead.

Also. please, try Google first. For example, an absence of git-gui--askpas might mean that there's no package git-gui installed.

Of course I know what environment variables are. But why should I install a GUI application on a Linux machine running on WSL2 when it is not possible to run that GUI? It is just not possible on a headless machine. Please read my posts more carefully next time.

That git-gui trick is just not the right workaround in my scenario. But maybe it works on the Mac if VSCode and the repository run natively in the same environment. Then @mohammedpatla only has to install git-gui on his system and needs to change the environment variables.

Of course I know what environment variables are. But why should I install a GUI application on a Linux machine running on WSL2 when it is not possible to run that GUI? It is just not possible on a headless machine.
That git-gui trick is just not the right workaround in my scenario.

Why are you trying to run VSCode on non-gui machine then or am I missing something?
Also, you might like to check out this one.

Works fine for me on my Mac, no matter how I start vscode, but I have the ssh-agent enabled and connected to my credential keychain so it starts automatically.

I haven't tried to pull/push from WSL, but I do use the vaccine remote connection. I am able to run guy applications from WSL using VcXsrv but that's irrelevant.

Is the ssh-agent started in your WSL? Start your WSL terminal and look at .bashrc or .bash_prifile, if they exist in your home folder. Then add:

eval `ssh-agent`
ssh-add

Maybe that will help but maybe not. When using wsl I've found some things just don't work. Keep your terminal open and sync your got repos manually

I think this is going too far, isn't it? We got workarounds already. The proper solution would be for VS Code to prompt for the password natively, in the same manner it already does for normal username/pass.

/cc @alarr46, what say you?

Of course I know what environment variables are. But why should I install a GUI application on a Linux machine running on WSL2 when it is not possible to run that GUI? It is just not possible on a headless machine.
That git-gui trick is just not the right workaround in my scenario.

Why are you trying to run VSCode on non-gui machine then or am I missing something?
Also, you might like to check out this one.
You misunderstood me. VSCode is running on Windows and the application and its sources I develop is running on WSL 2.
But thanks for you link. I didn't know about sharing Git credentials between Windows and WSL. I will test that.

On the other hand @ranolfi is right. All this are still workarounds. It would be better so fix that whole issue. :-)

Yes, I wish this to be implemented into VSCode, natively, too. A prompt would be highly appreciated.

Just add those keys bellow to your environment:

DISPLAY=needs-to-be-defined
SSH_ASKPASS=/mingw64/libexec/git-core/git-gui--askpass

before you ask yourself whether or not there should be a space before the double dashes, there shouldn't be. it looks like it should be a parameter but i believe it's actually a filename... no space

Just add those keys bellow to your environment:

DISPLAY=needs-to-be-defined
SSH_ASKPASS=/mingw64/libexec/git-core/git-gui--askpass

before you ask yourself whether or not there should be a space before the double dashes, there shouldn't be. it looks like it should be a parameter but i believe it's actually a filename... no space

I think this is going too far, isn't it? We got workarounds already. The proper solution would be for VS Code to prompt for the password natively, in the same manner it already does for normal username/pass.

/cc @alarr46, what say you?

Just gonna wait for the official release, just gonna use Git-CLI till then.

I think this is going too far, isn't it? We got workarounds already. The proper solution would be for VS Code to prompt for the password natively, in the same manner it already does for normal username/pass.

/cc @alarr46, what say you?

I agree, that is what I implemented in this pull request. It still needs to be reviewed though.

I agree, that is what I implemented in this pull request. It still needs to be reviewed though.

Very nice start, though. Thank you very much! Rocket.

Was this page helpful?
0 / 5 - 0 ratings