Skip to content

Commit 512d50d

Browse files
committed
Merge pull request #3 from mwielgoszewski/patch-1
Pass passphrase callback argument to importKey() method
2 parents cd66046 + 83964f5 commit 512d50d

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

decrypt-windows-ec2-passwd.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env python
22

3-
import base64, binascii, optparse, sys
3+
import base64, binascii, getpass, optparse, sys
44
from Crypto.PublicKey import RSA
55

66

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

0 commit comments

Comments
 (0)