允许代理转发使用 Cmder (ConEmu)

Allow agent forwarding using Cmder (ConEmu)

我在 Windows 8.1.

上使用 cmder which runs ConEmu

它有一个内置的 Git 功能,所以我可以 pull/push git 控制台中的存储库(就像在 Linux 控制台上一样)

为了进行身份验证,我使用了受密码保护的 SSH 私钥。如果我使用 ConEmu 执行 git push,它每次都会提示我输入密钥密码。我可以输入 'start-ssh-agent' 并输入一次密码,它会在 ConEmu window 中自动验证我的身份,但是如果我关闭或打开另一个 window,我需要 运行 再次命令。

我如何启动一个 ssh-agent 来验证我在每个 ConEmu window 中的密钥?

使用以下 snipped 在 Cmder 启动期间添加 SSH 密钥并且每个会话只输入一次密码:

@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

将代码添加到当前 Cmder 版本的 cmder/config/user-profile.cmd 或旧版本的 cmder/vendor/init.bat

编辑: 较新版本的 cmder 在 user-profile.cmd 中有以下行,使用 git:

:: uncomment this to have the ssh agent load when cmder starts
call "%GIT_INSTALL_ROOT%/cmd/start-ssh-agent.cmd"