Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Allow agent forwarding using Cmder (ConEmu)

I am using cmder which runs ConEmu on Windows 8.1.

It has a built in Git functionality so I can pull/push git repositories in the console (like on a Linux console)

To authenticate I use a password protected SSH private key. If I do a git push With ConEmu, it will prompt me for the keys password each time. I can type 'start-ssh-agent' and enter my password once, and it will will auto-authenticate me in that ConEmu window, however if I close or open another window I need to run the command again.

How can I start an ssh-agent that will authenticate my key in every ConEmu window?

like image 706
LondonAppDev Avatar asked Mar 24 '15 11:03

LondonAppDev


People also ask

What is Cmder ConEmu?

The “ConEmu” and “Cmder” is console software for developer or coder to execute commands. The “ConEmu” is free software for console users to execute WinAPI as well as Unix PTY commands. The “Cmder” is a software package for console users to execute PowerShell, CMD, Git commands easily.

What does SSH agent do?

The ssh-agent is a helper program that keeps track of user's identity keys and their passphrases. The agent can then use the keys to log into other servers without having the user type in a password or passphrase again. This implements a form of single sign-on (SSO).


1 Answers

With the following snipped the SSH key is added during the startup of Cmder and the password has only be entered once per session:

@echo off
ssh-agent | grep -v echo | sed -e "s/^/@set /" | sed -e "s/;.*$//" - > call.cmd
call call.cmd
del call.cmd
ssh-add "%HOME%\.ssh\id_rsa"
@echo on

Add the code to cmder/config/user-profile.cmd in the current Cmder version or to cmder/vendor/init.bat for older versions.

Edit: Newer versions of cmder have the following lines in the user-profile.cmd which does the same using git:

:: uncomment this to have the ssh agent load when cmder starts
call "%GIT_INSTALL_ROOT%/cmd/start-ssh-agent.cmd"
like image 187
bastelflp Avatar answered Sep 27 '22 15:09

bastelflp