Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to enable ssh-agent? #193

Closed
CaseyLabs opened this issue May 14, 2014 · 32 comments
Closed

How to enable ssh-agent? #193

CaseyLabs opened this issue May 14, 2014 · 32 comments

Comments

@CaseyLabs
Copy link

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!

@ccoenen
Copy link

ccoenen commented Sep 30, 2014

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

@bojanrajkovic
Copy link

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.

@ccoenen
Copy link

ccoenen commented Oct 8, 2014

Sweeet! Works as advetised :-)

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

@Shoozza
Copy link
Contributor

Shoozza commented Oct 28, 2014

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

@bojanrajkovic
Copy link

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.

@ogrim
Copy link
Contributor

ogrim commented Nov 12, 2014

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.

@rmorrin
Copy link
Contributor

rmorrin commented Nov 13, 2014

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.

@Shoozza
Copy link
Contributor

Shoozza commented Nov 14, 2014

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

@ogrim
Copy link
Contributor

ogrim commented Nov 14, 2014

Thanks, @Shoozza. It's working fine for me now 👍

@rmorrin
Copy link
Contributor

rmorrin commented Nov 14, 2014

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

@ogrim
Copy link
Contributor

ogrim commented Nov 14, 2014

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

@Shoozza
Copy link
Contributor

Shoozza commented Nov 14, 2014

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

@rmorrin
Copy link
Contributor

rmorrin commented Nov 14, 2014

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

@lokifer
Copy link

lokifer commented Dec 3, 2014

@Shoozza Cheers, this is fantastic.

@RDeluxe
Copy link

RDeluxe commented Dec 15, 2014

This need to be added to the repo !

@ccoenen
Copy link

ccoenen commented Dec 15, 2014

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

@MartiUK
Copy link
Member

MartiUK commented Dec 16, 2014

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

ogrim added a commit to ogrim/cmder that referenced this issue Dec 17, 2014
Adding agent-script to bin-folder and a commented out call in init.bat
@ogrim
Copy link
Contributor

ogrim commented Dec 17, 2014

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

ogrim added a commit to ogrim/cmder that referenced this issue Dec 17, 2014
Adding agent-script to bin-folder and a commented out call in init.bat
MartiUK added a commit that referenced this issue Dec 18, 2014
Adding script to enable SSH-agent #193
@teleivo
Copy link

teleivo commented Dec 23, 2014

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: hashicorp/vagrant#1735

thanks a lot for cmder :)

@cdelgehier
Copy link

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

@cdelgehier
Copy link

With your script @teleivo and http://niki.hammler.net/wiki/PuttyAgent_now_supports_openssh/cygwin/msys
I am a satisfied man

@IrNoThnk
Copy link

IrNoThnk commented Feb 9, 2015

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.

@isdsc
Copy link

isdsc commented Feb 24, 2015

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?

@LondonAppDev
Copy link

@isdsc any idea how to make it enable agent forwarding?

@isdsc
Copy link

isdsc commented Mar 21, 2015

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

  1. I don't know the specifics of your situation.
  2. I don't think I have used ssh in that way (unless that's what's going on behind the scenes when I connect to GitHub).

@airtonix
Copy link

@isdsc regarding 2. no. it is not. if you've never chained ssh tunnels together then you've never used agent-forwarding.

@SpacemanPete
Copy link

@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.ssh" location listed in there...

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...

@OleksiiShevchenko
Copy link

Thanks, works great!

AlphaGit added a commit to AlphaGit/cmder that referenced this issue Jun 5, 2017
(and some comments on the user-profile.cmd file)

Inspired by the comments from cmderdev#193 and my personal need to use pageant instead of OpenSSH authentication agents (which is more Window user-friendly), I have used this approach which works as expected.

Keeping the spirit of the current scripts, I left it disabled, and with some comments explaining what they all do.
Stanzilla pushed a commit that referenced this issue Jul 24, 2017
(and some comments on the user-profile.cmd file)

Inspired by the comments from #193 and my personal need to use pageant instead of OpenSSH authentication agents (which is more Window user-friendly), I have used this approach which works as expected.

Keeping the spirit of the current scripts, I left it disabled, and with some comments explaining what they all do.
Stanzilla pushed a commit that referenced this issue Jul 24, 2017
(and some comments on the user-profile.cmd file)

Inspired by the comments from #193 and my personal need to use pageant instead of OpenSSH authentication agents (which is more Window user-friendly), I have used this approach which works as expected.

Keeping the spirit of the current scripts, I left it disabled, and with some comments explaining what they all do.
daxgames pushed a commit to daxgames/cmder that referenced this issue Mar 7, 2018
(and some comments on the user-profile.cmd file)

Inspired by the comments from cmderdev#193 and my personal need to use pageant instead of OpenSSH authentication agents (which is more Window user-friendly), I have used this approach which works as expected.

Keeping the spirit of the current scripts, I left it disabled, and with some comments explaining what they all do.
daxgames pushed a commit to daxgames/cmder that referenced this issue Mar 7, 2018
(and some comments on the user-profile.cmd file)

Inspired by the comments from cmderdev#193 and my personal need to use pageant instead of OpenSSH authentication agents (which is more Window user-friendly), I have used this approach which works as expected.

Keeping the spirit of the current scripts, I left it disabled, and with some comments explaining what they all do.
@ilan-schemoul
Copy link

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

@jocafi
Copy link

jocafi commented Jul 6, 2023

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.

@Mooninaut
Copy link

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.

@renandecarlo
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests