diff options
author | Robey Pointer <robey@lag.net> | 2004-04-05 19:36:40 +0000 |
---|---|---|
committer | Robey Pointer <robey@lag.net> | 2004-04-05 19:36:40 +0000 |
commit | c6d5ba9c5225b119bd718b4fbc1523dc9b3a3926 (patch) | |
tree | d611d1a1d8d82ede5af4a172b3e382ce2a22cb5d /demo.py | |
parent | 70faf02f3eb9ecd6d33f23881fca9b9057ff297f (diff) |
[project @ Arch-1:robey@lag.net--2003-public%secsh--dev--1.0--patch-40]
add dss key generation too, and fix some bugs
added the ability to generate dss keys and write private dss key files,
similar to rsa. in the process, fixed a couple of bugs with ber encoding
and writing password-encrypted key files. the key has to be padded to the
iblock size of the cipher -- it's very difficult to determine how the others
do this, so i just add random bytes to the end.
fixed the simple demo to use Transport's (host, port) constructor for
simplicity, and fixed a bug where the standard demo's DSS login wouldn't
work.
also, move the common logfile setup crap into util so all the demos can just
call that one.
Diffstat (limited to 'demo.py')
-rwxr-xr-x | demo.py | 20 |
1 files changed, 6 insertions, 14 deletions
@@ -31,13 +31,7 @@ def load_host_keys(): ##### main demo # setup logging -l = logging.getLogger("paramiko") -l.setLevel(logging.DEBUG) -if len(l.handlers) == 0: - f = open('demo.log', 'w') - lh = logging.StreamHandler(f) - lh.setFormatter(logging.Formatter('%(levelname)-.3s [%(asctime)s] %(name)s: %(message)s', '%Y%m%d:%H%M%S')) - l.addHandler(lh) +paramiko.util.log_to_file('demo.log') username = '' @@ -103,29 +97,27 @@ try: auth = default_auth if auth == 'r': - key = paramiko.RSAKey() default_path = os.environ['HOME'] + '/.ssh/id_rsa' path = raw_input('RSA key [%s]: ' % default_path) if len(path) == 0: path = default_path try: - key.read_private_key_file(path) + key = paramiko.RSAKey.from_private_key_file(path) except paramiko.PasswordRequiredException: password = getpass.getpass('RSA key password: ') - key.read_private_key_file(path, password) + key = paramiko.RSAKey.from_private_key_file(path, password) t.auth_publickey(username, key, event) elif auth == 'd': - key = paramiko.DSSKey() default_path = os.environ['HOME'] + '/.ssh/id_dsa' path = raw_input('DSS key [%s]: ' % default_path) if len(path) == 0: path = default_path try: - key.read_private_key_file(path) + key = paramiko.DSSKey.from_private_key_file(path) except paramiko.PasswordRequiredException: password = getpass.getpass('DSS key password: ') - key.read_private_key_file(path, password) - t.auth_key(username, key, event) + key = paramiko.DSSKey.from_private_key_file(path, password) + t.auth_publickey(username, key, event) else: pw = getpass.getpass('Password for %s@%s: ' % (username, hostname)) t.auth_password(username, pw, event) |