Skip to content

Instantly share code, notes, and snippets.

@KhodeN
Created June 1, 2014 02:47
Show Gist options
  • Save KhodeN/31af1b2f6be986f20fe7 to your computer and use it in GitHub Desktop.
Save KhodeN/31af1b2f6be986f20fe7 to your computer and use it in GitHub Desktop.
Start PAGEANT.EXE (ssh-agent for windows) with all *.ppk, collected recursively
import os
import sys
def get_files(only_ext):
for root, sub_folders, files in os.walk("."):
for file in files:
name, ext = os.path.splitext(file)
if ext == only_ext:
yield os.path.join(root, file)[2:]
pa_path = "..\\..\\PortableSoft\\putty\\PAGEANT.EXE"
keys = list(get_files(".ppk"))
#first (index 0) argument is program itself
os.execv(pa_path, [pa_path] + keys)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment