-
-
Save ernstki/da1e685e22c90a684ae7 to your computer and use it in GitHub Desktop.
A simple batch wrapper around PuTTY's PLINK.EXE to fix EGit/Pageant integration on Windows for non-standard SSH port numbers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@ECHO OFF | |
:: A simple batch script wrapper around PuTTY's PLINK.EXE | |
:: to integrate with Eclipse's EGit plugin. Update your | |
:: remote [username] below and save this script as | |
:: 'plink.cmd' alongside wherever PLINK.EXE is installed | |
:: on your system. | |
:: | |
:: The SO article referenced below will show you how to | |
:: use this script with EGit (hint: set the GIT_SSH | |
:: environment variable to the full pathname to this | |
:: script using Win + R -> rundll32 | |
:: sysdm.cpl,EditEnvironmentVariables). | |
:: | |
:: This script isn't actually required *except* when you | |
:: need to connect to a remote host on a non-standard | |
:: port number. EGit, out of the box, will fail to | |
:: connect because of PLINK's insistence on using '-P' | |
:: (upper-case -P) for its "port number" command line | |
:: option; this script just filters the '-p <portnum>' | |
:: supplied by EGit into the '-P <portumn>' required by | |
:: PLINK. | |
:: | |
:: Source: https://stackoverflow.com/a/11763013 | |
:: Short URL for this gist: http://bit.ly/plink-cmd | |
:: ####################################################### | |
:: # CHANGE [username] HERE TO YOUR REMOTE USERNAME # | |
:: ####################################################### | |
set REMOTE_USER=[username] | |
:: If EGit isn't seeting the working directory before | |
:: running the program specified by the %GIT_SSH% | |
:: environment variable, you may want to change this to | |
:: say "%0\..\plink.exe ..." (which is a batch scripting | |
:: trick that means "in the same directory as me"). | |
SET c=plink.exe -ssh -agent -l %REMOTE_USER% | |
:: Parse the command line options passed to this script | |
:: and change the '-p' option supplied by EGit to the '-P' | |
:: option expected by PLINK. | |
:loop | |
if NOT _%1_ == __ ( | |
IF _%1_ == _-p_ ( | |
SET c=%C% -P | |
) else ( | |
SET c=%C% %1 | |
) | |
shift | |
goto loop | |
) | |
:: Now run PLINK with the accumulated options | |
%c% |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment