Skip to content

Instantly share code, notes, and snippets.

@justinAurand
Forked from teleivo/pageant_autostart.cmd
Last active September 11, 2020 11:04
Show Gist options
  • Save justinAurand/076cc3468a5af6c6c1b6718bcd438b1d to your computer and use it in GitHub Desktop.
Save justinAurand/076cc3468a5af6c6c1b6718bcd438b1d to your computer and use it in GitHub Desktop.
Run pageant and add keys on Cmder startup
setlocal ENABLEDELAYEDEXPANSION
set ssh_key_home=%HOME%\.ssh\
set pageant_key_wildcard=*.ppk
echo Gathering keys matching %pageant_key_wildcard% in ^
%ssh_key_home%
rem Check if pageant is running
for /f "tokens=2 delims=," %%F in ('tasklist /nh /fi "imagename eq PAGEANT.EXE" /fo csv') do (
set pageant_pid=%%F
)
echo Starting pageant
if "%pageant_pid%" == "" (start pageant.exe)
rem Get pageant style keys
for /f "tokens=*" %%I in ('DIR /B "%ssh_key_home%%pageant_key_wildcard%"') do (
echo Adding key %ssh_key_home%%%%I
pageant "%ssh_key_home%%%I"
)
endlocal
@justinAurand
Copy link
Author

justinAurand commented Jan 19, 2018

  1. Place this file in %CMDER_ROOT%\vendor.
  2. Open init.bat, also located in %CMDER_ROOT%\vendor, as admin.
  3. Place @call "%CMDER_ROOT%/vendor/pageant_autostart.cmd" before the exit /b that's immediately before the subroutine section near the end of the file .

@bjesuiter
Copy link

This is awesome!
I searched for an ethernity to get this running :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment