Fix demo_keygen
This commit is contained in:
parent
7a45d3c70f
commit
8bda3ab2bb
|
@ -19,7 +19,6 @@
|
||||||
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
||||||
from __future__ import with_statement
|
from __future__ import with_statement
|
||||||
|
|
||||||
import string
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from binascii import hexlify
|
from binascii import hexlify
|
||||||
|
@ -28,6 +27,7 @@ from optparse import OptionParser
|
||||||
from paramiko import DSSKey
|
from paramiko import DSSKey
|
||||||
from paramiko import RSAKey
|
from paramiko import RSAKey
|
||||||
from paramiko.ssh_exception import SSHException
|
from paramiko.ssh_exception import SSHException
|
||||||
|
from paramiko.py3compat import u
|
||||||
|
|
||||||
usage="""
|
usage="""
|
||||||
%prog [-v] [-b bits] -t type [-N new_passphrase] [-f output_keyfile]"""
|
%prog [-v] [-b bits] -t type [-N new_passphrase] [-f output_keyfile]"""
|
||||||
|
@ -47,16 +47,16 @@ key_dispatch_table = {
|
||||||
def progress(arg=None):
|
def progress(arg=None):
|
||||||
|
|
||||||
if not arg:
|
if not arg:
|
||||||
print '0%\x08\x08\x08',
|
sys.stdout.write('0%\x08\x08\x08 ')
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
elif arg[0] == 'p':
|
elif arg[0] == 'p':
|
||||||
print '25%\x08\x08\x08\x08',
|
sys.stdout.write('25%\x08\x08\x08\x08 ')
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
elif arg[0] == 'h':
|
elif arg[0] == 'h':
|
||||||
print '50%\x08\x08\x08\x08',
|
sys.stdout.write('50%\x08\x08\x08\x08 ')
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
elif arg[0] == 'x':
|
elif arg[0] == 'x':
|
||||||
print '75%\x08\x08\x08\x08',
|
sys.stdout.write('75%\x08\x08\x08\x08 ')
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
@ -92,8 +92,8 @@ if __name__ == '__main__':
|
||||||
parser.print_help()
|
parser.print_help()
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
for o in default_values.keys():
|
for o in list(default_values.keys()):
|
||||||
globals()[o] = getattr(options, o, default_values[string.lower(o)])
|
globals()[o] = getattr(options, o, default_values[o.lower()])
|
||||||
|
|
||||||
if options.newphrase:
|
if options.newphrase:
|
||||||
phrase = getattr(options, 'newphrase')
|
phrase = getattr(options, 'newphrase')
|
||||||
|
@ -106,7 +106,7 @@ if __name__ == '__main__':
|
||||||
if ktype == 'dsa' and bits > 1024:
|
if ktype == 'dsa' and bits > 1024:
|
||||||
raise SSHException("DSA Keys must be 1024 bits")
|
raise SSHException("DSA Keys must be 1024 bits")
|
||||||
|
|
||||||
if not key_dispatch_table.has_key(ktype):
|
if ktype not in key_dispatch_table:
|
||||||
raise SSHException("Unknown %s algorithm to generate keys pair" % ktype)
|
raise SSHException("Unknown %s algorithm to generate keys pair" % ktype)
|
||||||
|
|
||||||
# generating private key
|
# generating private key
|
||||||
|
@ -121,7 +121,7 @@ if __name__ == '__main__':
|
||||||
f.write(" %s" % comment)
|
f.write(" %s" % comment)
|
||||||
|
|
||||||
if options.verbose:
|
if options.verbose:
|
||||||
print "done."
|
print("done.")
|
||||||
|
|
||||||
hash = hexlify(pub.get_fingerprint())
|
hash = u(hexlify(pub.get_fingerprint()))
|
||||||
print "Fingerprint: %d %s %s.pub (%s)" % (bits, ":".join([ hash[i:2+i] for i in range(0, len(hash), 2)]), filename, string.upper(ktype))
|
print("Fingerprint: %d %s %s.pub (%s)" % (bits, ":".join([ hash[i:2+i] for i in range(0, len(hash), 2)]), filename, ktype.upper()))
|
||||||
|
|
Loading…
Reference in New Issue