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_simple.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_simple.py')
-rwxr-xr-x | demo_simple.py | 22 |
1 files changed, 3 insertions, 19 deletions
diff --git a/demo_simple.py b/demo_simple.py index 0bd877c2..6a216b28 100755 --- a/demo_simple.py +++ b/demo_simple.py @@ -29,13 +29,7 @@ def load_host_keys(): # 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') # get hostname username = '' @@ -73,19 +67,9 @@ if hkeys.has_key(hostname): print 'Using host key of type %s' % hostkeytype -# now connect +# now, connect and use paramiko Transport to negotiate SSH2 across the connection try: - sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - sock.connect((hostname, port)) -except Exception, e: - print '*** Connect failed: ' + str(e) - traceback.print_exc() - sys.exit(1) - - -# finally, use paramiko Transport to negotiate SSH2 across the connection -try: - t = paramiko.Transport(sock) + t = paramiko.Transport((hostname, port)) t.connect(username=username, password=password, hostkeytype=hostkeytype, hostkey=hostkey) chan = t.open_session() chan.get_pty() |