Skip to content

Commit

Permalink
Merge pull request #3 from mwielgoszewski/patch-1
Browse files Browse the repository at this point in the history
Pass passphrase callback argument to importKey() method
  • Loading branch information
tomrittervg committed Oct 20, 2013
2 parents cd66046 + 83964f5 commit 512d50d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions decrypt-windows-ec2-passwd.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python

import base64, binascii, optparse, sys
import base64, binascii, getpass, optparse, sys
from Crypto.PublicKey import RSA


Expand Down Expand Up @@ -75,10 +75,10 @@ def decryptPassword(rsaKey, password):
keyLines = keyFile.readlines()
#Import it
try:
key = RSA.importKey(keyLines)
except:
key = RSA.importKey(keyLines, passphrase=getpass.getpass('Encrypted Key Password (leave blank if none): '))
except ValueError:
print "Could not import SSH Key (Is it an RSA key? Is it password protected?)"
sys.exit(-1)
#Decrypt it
print ""
print "Password:", decryptPassword(key, options.password)
print "Password:", decryptPassword(key, options.password)

0 comments on commit 512d50d

Please sign in to comment.