Open clounie opened 5 years ago
What is the path to your .ssh
directory in this case?
Not a fun one, haha. I have no idea how often (or if) the Canonical* folder changes.
C:\Users\Eos\AppData\Local\Packages\CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc\LocalState\rootfs\home\clounie\.ssh
That's the same path as when I open Ubuntu shell in WSL and typed cd ~/.ssh
However Ubuntu is not the only distro available from the Windows Store - given that + the ridiculous path I figured having an "advanced" option for an absolute path might be simpler.
I think the more 'correct' (?) solution to this would be to integrate Fork with WSL Ubuntu's ssh-agent
?
In WSL Ubuntu once ssh-agent
is running with your private key added to it, then the distro of git
within WSL Ubuntu (which is completely separate from Git for Windows, btw) automatically uses this to get its private keys.
How to set up ssh-agent
on WSL Ubuntu?
ssh-agent
installed (it is from the openssh-client
package)git
installed (it is from the git
package)~/.ssh/id_rsa
(with permissions 600)If you now execute a git command against an ssh enabled remote ([git@bitbucket.org:[user]/[repo].git]() or [git@github.com:[user]/[repo].git]()) then you should be prompted for your private key's password and the command should then succeed. If you execute the command again, you'll be prompted for your password again.
Finally, we want to set up ssh-agent
so that we don't have to enter the password each time:
.bashrc
filessh-agent
is already runningSuggestion
My suggestion would be that since this all works already, then the correct and clean way to integrate Fork with WSL Ubuntu private keys is to integrate it with WSL Ubuntu ssh-agent
(somehow!).
However...
@clounie - There is already a workaround for this:
~.ssh/id_rsa
) file; it's pretty self-explanatory actually, but for completeness see the instructions I added on related issue #179 in this repoThis all works for me. I've had my Pageant .ppk setup running for ages (for PuTTY, FileZilla, GfW, VS, VS Code, etc.), so I wasn't surprised that this just worked! I am 99.9% sure I am not doing anything weird or non-standard here!
That's cool Mike - will try tonight! Thanks for all the details.
UPDATE:
Oh dear, one crucial item which I forget to include (because I already had it from ages ago and couldn't see that it was missing until I came to re-do this on a brand new machine):
You must set the environment variable:
GIT_SSH=C:\Program Files\PuTTY\plink.exe
(which, importantly, must not include double quotes in the value).
(https://stackoverflow.com/a/43313491/795690)
Already added to the instructions I put up on #179.
Sorry for forgetting this and @DanPristupov possibly the explantion for how I "made it work so easily"!
(and ping @clounie)
If you use GfW there is no need to download Putty at all. It comes with everything required. This works perfectly: https://help.github.com/en/github/authenticating-to-github/working-with-ssh-key-passphrases#auto-launching-ssh-agent-on-git-for-windows
Also, for WSL, I store the ssh credentials in the standard Windows location (where fork expects them by default), which is %USERPROFILE%\.ssh
. In WSL1 I just copy them over, you could even automate that in bashrc if you expect the keys to change often:
cp -r $WINDOWSHOME/.ssh ~/.ssh
chmod 600 ~/.ssh/*
This makes all tools happy.
This is pretty cool:
https://github.com/benpye/wsl-ssh-pageant
It lets you keep your SSH keys in one place (Pageant, or in theory another compatible agent), which with this are made accessible to WSL ssh
, git
, etc. commands. Pageant keys are already accessible by basically everything else, including Fork, via GfW.
(Not a strict answer to the OP question, but a pretty viable alternative in many cases, I would think - if the main aim is just to have authentication keys in one place, not multiple.)
Hi, i'm trying to do something linked to this topic; maybe you can help me. I have open ssh agent on windows, without any keys; and i load my ssh keys using KeePassXD (which is kind of nice :) ) i share the agent with my WSL instance, meaning, any key loaded in windows is usable from my WSL : nice. now when i run fork, it's looks like it's not using the same agent. i switched the setting to use the git.exe which is in program files, doesn't help. I changed the shell from "git shell" to "windows terminal", and first, i had "no agent running", now i have "no keys loaded". But my keys are loaded (see screenshot) is there a way i can force fork to use "the agent i'm using" (i'm no expert on tha matter, i actually didn't know i could have many, if i do). Does anyone have any idea how i can solve the problem ? i currently use fork as read only (because i like the branch visualisation), but i push,pull, fetch from the command line
thanks !
I have open ssh agent on windows, without any keys; and i load my ssh keys using KeePassXD (which is kind of nice :) ) i share the agent with my WSL instance, meaning, any key loaded in windows is usable from my WSL : nice.
How did you share KeePassXD agent with WLS instance? How does it find an SSH agent and decide which one to use?
Fork doesn't communicate with SSH agent directly. Does Fetch work in you open console in Fork and run git fetch
?
you can find many tutorials to share the keepass agent with WSL, i followed this one: https://medium.com/@wondrous_oxblood_cheetah_508/ssh-agent-on-windows-c74b90fb2e31
i copy here the part you ask about:
Using the Windows ssh-agent in WSL
Did you know, you can directly call & run.exe files in your WSL terminal? This makes this whole section extremely simple!
Just add these two lines to your
~/.bashrc
or equivalent file and you’re done!alias ssh-add='ssh-add.exe' alias ssh='ssh-add.exe -l > /dev/null || ssh-add.exe && echo -e "\e[92mssh-key(s) are now available in your ssh-agent until you lock your windows machine! \n \e[0m" && ssh.exe'
If you also want git to use ssh.exe, just enter:
git config --global core.sshcommand "ssh.exe"
and it's very convenient by the way :-D
I have open ssh agent on windows, without any keys; and i load my ssh keys using KeePassXD (which is kind of nice :) ) i share the agent with my WSL instance, meaning, any key loaded in windows is usable from my WSL : nice.
How did you share KeePassXD agent with WLS instance? How does it find an SSH agent and decide which one to use?
Fork doesn't communicate with SSH agent directly. Does Fetch work in you open console in Fork and run
git fetch
?
i cannot git fetch (because no key is loaded) (right screen shot does not include the failed git fetch, sorry)
also, since last time i changed the fork terminal, i have something different now, which match what you said:
i changed the terminal to use; now i can see my key is loaded in both terminal (the regular WSL terminal AND the "fork terminal")
but unfortunately, i cannot git fetch/git pull (i also specifyed : git config --global core.sshcommand "ssh.exe"
and it didn't work either)
For WSL users it would help to be able to specify the location of your SSH key.
On my home windows computer, it's hidden away in a Linux-only directory. If I had the ability to specify an absolute path for the Git key, I could just select the key and be done with it.