Closed CaseyLabs closed 9 years ago
same problem here, if someone is using this without problems i would appreciate a hint on how to set it up.
I came up with this gist, which does the trick: https://gist.github.com/bojanrajkovic/6997145eda613467ace4. You can add this to init.bat. I'd love some input from @bliker or someone else as to how to get this to run on "startup" without being overwritten by Cmder upgrades.
Sweeet! Works as advetised :-)
I would even go as far as making this an official option (perhaps not default, but an option nonetheless!)
I wrote another solution for the problem which doesn't run ssh-agent for each new Cmder instance.
It works without temporary files, only runs ssh-agent when it isn't running and adds ssh keys in %HOME%.ssh*_rsa if they were not yet added.
Nice, that's much better than my hack. I've switched to Powershell + posh-git in the meantime (which has built-in support for ssh-agent), but this is a cool solution.
Using the script from @bojanrajkovic it works for me. With @Shoozza's fix I only get: "Could not open a connection to your authentication agent". Strange, I don't see why the call to ssh-add shouldn't work in the second script as well.
I get the same with @Shoozza 's fix also: Could not open a connection to your authentication agent
. Would be nice to resolve as it's a cleaner workaround for this issue.
Rewrote the script to handle the issue (revision 7). The problem was that another ssh-agent was running already and didn't use the /tmp/ssh-agent.sock. @ogrim @rmorrin
Thanks, @Shoozza. It's working fine for me now :+1:
@ogrim Same for me - thanks @Shoozza! Is there a way to automatically run this each time a new Cmder window/tab is opened?
You can add it to cmder/vendor/init.bat
. I have the script on my path as agent.cmd
, so I have only added call agent
as the last line in init.bat
I added @call "%CMDER_ROOT%/vendor/agent.cmd"
at the end of cmder/vendor/init.bat
.
@ogrim @Shoozza Thanks, exactly what I was looking for! This has been a huge headache for me with Cmder for a long time - you should definitely submit a PR :+1:
@Shoozza Cheers, this is fantastic.
This need to be added to the repo !
I'm taking the liberty of notifying @bliker directly. I hope he doesn't mind. This shoud be part of cmder for sure :D
If someone adds a pull request to add the file there shouldn't be a problem.
I went ahead and made pull request #351, thanks everyone!
Based on your great solution, a script which loads keys into putty's pageant. https://gist.github.com/teleivo/2eb7dd6afbda414c9269
Same as above add @call "%CMDER_ROOT%/vendor/pageant_autostart.cmd"
at the end of cmder/vendor/init.bat
pageant helps those who want to use vagrant on windows with puppets vcsrepo to clone private git repos: https://github.com/mitchellh/vagrant/issues/1735
thanks a lot for cmder :)
It is working for me but the agent forwarding is not good How to export SOCK and PID variable?
With your script @teleivo and http://niki.hammler.net/wiki/PuttyAgent_now_supports_openssh/cygwin/msys I am a satisfied man
has anyone successfully had confirmation with ssh-add working?
ssh-add -c /path/to/key
Adding is no problem, but you'll get a failure when connecting because there is no /usr/libexec/ssh-askpass. At least that's the issue that I've had in Ubuntu before.
I am currently using start-ssh-agent
script provided by msysgit to set up my ssh-agent in cmder (it is in the default cmder search path: %git_install_root%\cmd). Is there any reason to switch to the one added to the development branch?
@isdsc any idea how to make it enable agent forwarding?
@markwint if the question is how start-ssh-agent
works with agent forwarding, the answer is (AFAIK):
It just starts
ssh-agent
properly in your session [in Windows console] and adds the default identity, it doesn't deal with agent forwarding.
Here is my ssh configuration:
λ head ~/.ssh/config
# Shortcut to connect to my server
Host mysvc
User MyName
IdentityFile ~/.ssh/id_rsa
HostName myservice.example.com
# GitHub account: isdsc
Host github.com
IdentityFile ~/.ssh/isdsc
HostName github.com
Here is how I use agent forwarding with a second identity to connect to GitHub. See GitHub for details.
λ start-ssh-agent
Removing old ssh-agent sockets
Starting ssh-agent: done
Enter passphrase for /c/Users/MyName/.ssh/id_rsa:
Identity added: /c/Users/MyName/.ssh/id_rsa (/c/Users/MyName/.ssh/id_rsa)
λ ssh-add ~/.ssh/isdsc
Enter passphrase for /c/Users/MyName/.ssh/isdsc:
Identity added: /c/Users/MyName/.ssh/isdsc (/c/Users/MyName/.ssh/isdsc)
λ ssh -T git@github.com
Hi isdsc! You've successfully authenticated, but GitHub does not provide shell access.
However, just to make sure I understood what agent forwarding means, I googled it and found another explanation: http://www.unixwiz.net/techtips/ssh-agent-forwarding.html#fwd
If your question is about this second interpretation, I don't know how to respond to your question because:
@isdsc regarding 2. no. it is not. if you've never chained ssh tunnels together then you've never used agent-forwarding.
@teleivo, your option seems to be the one that would fit my eneeds best, but I get an error that >'pageant' is not recognized as an internal or external command, operable program or batch file.<
even though the %PATH% has my "C:\Users
I edited the pageant_autostart.cmd file to list the full explicit path to pageant.exe and it works but i'm puzzled why cmder can't find pageant...
Thanks, works great!
For futur people the equivalent to linux's eval seems to be call so to call ssh-agent it would be call %GIT_INSTALL_ROOT%/cmd/start-ssh-agent.cmd
I noticed that I had to start the Windows service "OpenSSH Authentication Agent". I think this advice may help some solution here to work, specially the solution from @bojanrajkovic . In my case, after putting his Gist in the CMder settings, I had only to execute the command "ssh-add.exe" in the CLI. If I add optional arguments like "ssh-add.exe %HOME%.ssh\id_ed25519" , it does not work.
The latest version of start-ssh-agent.cmd
seems to open a cmd
shell with the arguments provided to it on the command line, which was giving me a shell with no Cmder magic. I changed my default {cmd::Cmder}
task to run "C:\Program Files\Git\cmd\start-ssh-agent.cmd" /k ""%ConEmuDir%\..\init.bat" "
and that worked for me.
For some reason either ssh-agent or ssh-pageant is working for me. It asks for password on startup, but then it asks again when I ssh to a server.
I'm trying to setup Cmder to use ssh-agent forwarding:
λ ssh-agent SSH_AUTH_SOCK=/tmp/ssh-JqBCMa6092/agent.6092; export SSH_AUTH_SOCK; SSH_AGENT_PID=7840; export SSH_AGENT_PID; echo Agent pid 7840;
λ ssh-add my-public-key.pub Could not open a connection to your authentication agent
Any ideas what I'm doing wrong here?
Thank!