Skip to content

Instantly share code, notes, and snippets.

@mattn
Created March 12, 2010 11:20
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mattn/330238 to your computer and use it in GitHub Desktop.
Save mattn/330238 to your computer and use it in GitHub Desktop.
windowsではssh-askpassが使えないのでsetxで環境変数に設定しちゃうぞバッチファイル
@echo off
if "%1" == "-f" goto doit
if "%1" == "-s" goto session
if not "%SSH_AGENT_PID%" == "" goto end
goto doit
:session
for /f "eol=; tokens=1,2 delims==;" %%1 in ('ssh-agent.exe') do (
if "%%1" == "SSH_AUTH_SOCK" setx SSH_AUTH_SOCK %%2 & set SSH_AUTH_SOCK=%%2
if "%%1" == "SSH_AGENT_PID" setx SSH_AGENT_PID %%2 & set SSH_AGENT_PID=%%2
)
goto bottom
:doit
for /f "eol=; tokens=1,2 delims==;" %%1 in ('ssh-agent.exe') do (
if "%%1" == "SSH_AUTH_SOCK" set SSH_AUTH_SOCK=%%2
if "%%1" == "SSH_AGENT_PID" set SSH_AGENT_PID=%%2
)
:bottom
ssh-add
:end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment