cmder icon indicating copy to clipboard operation
cmder copied to clipboard

How to enable ssh-agent?

Open CaseyLabs opened this issue 12 years ago • 32 comments

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!

CaseyLabs avatar May 14 '14 05:05 CaseyLabs

same problem here, if someone is using this without problems i would appreciate a hint on how to set it up.

ccoenen avatar Sep 30 '14 08:09 ccoenen

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.

bojanrajkovic avatar Oct 05 '14 17:10 bojanrajkovic

Sweeet! Works as advetised :-)

I would even go as far as making this an official option (perhaps not default, but an option nonetheless!)

ccoenen avatar Oct 08 '14 09:10 ccoenen

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.

https://gist.github.com/Shoozza/8fe8b0c85fa89cd3b1c4

Shoozza avatar Oct 28 '14 13:10 Shoozza

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.

bojanrajkovic avatar Oct 28 '14 13:10 bojanrajkovic

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.

ogrim avatar Nov 12 '14 10:11 ogrim

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.

rmorrin avatar Nov 13 '14 10:11 rmorrin

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

Shoozza avatar Nov 14 '14 09:11 Shoozza

Thanks, @Shoozza. It's working fine for me now :+1:

ogrim avatar Nov 14 '14 09:11 ogrim

@ogrim Same for me - thanks @Shoozza! Is there a way to automatically run this each time a new Cmder window/tab is opened?

rmorrin avatar Nov 14 '14 10:11 rmorrin

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

ogrim avatar Nov 14 '14 10:11 ogrim

I added @call "%CMDER_ROOT%/vendor/agent.cmd" at the end of cmder/vendor/init.bat.

Shoozza avatar Nov 14 '14 10:11 Shoozza

@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:

rmorrin avatar Nov 14 '14 10:11 rmorrin

@Shoozza Cheers, this is fantastic.

lokifer avatar Dec 03 '14 05:12 lokifer

This need to be added to the repo !

RDeluxe avatar Dec 15 '14 21:12 RDeluxe

I'm taking the liberty of notifying @bliker directly. I hope he doesn't mind. This shoud be part of cmder for sure :D

ccoenen avatar Dec 15 '14 22:12 ccoenen

If someone adds a pull request to add the file there shouldn't be a problem.

MartiUK avatar Dec 16 '14 17:12 MartiUK

I went ahead and made pull request #351, thanks everyone!

ogrim avatar Dec 17 '14 07:12 ogrim

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 :)

teleivo avatar Dec 23 '14 13:12 teleivo

It is working for me but the agent forwarding is not good How to export SOCK and PID variable?

cdelgehier avatar Jan 23 '15 12:01 cdelgehier