From 2939b6936b50d207048d9e245c202c6a7c705643 Mon Sep 17 00:00:00 2001 From: Robey Pointer Date: Mon, 18 Oct 2004 04:54:27 +0000 Subject: [project @ Arch-1:robey@lag.net--2003-public%secsh--dev--1.0--patch-93] switch Transport.connect() to using a Pkey object for the host key i suddenly realized that passing "hostkeytype" and "hostkey" as strings to Transport.connect() was pretty silly since i went to all the effort of making a class specifically for holding keys. so Transport.connect() now just takes host-key argument: "hostkey" as a PKey object. updated the demos to use PKey objects when reading the host key file, and to use the new "hostkey" argument. --- demo.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'demo.py') diff --git a/demo.py b/demo.py index dfb7231f..9633c5ca 100755 --- a/demo.py +++ b/demo.py @@ -23,7 +23,10 @@ def load_host_keys(): for host in hosts: if not keys.has_key(host): keys[host] = {} - keys[host][keytype] = base64.decodestring(key) + if keytype == 'ssh-rsa': + keys[host][keytype] = paramiko.RSAKey(data=base64.decodestring(key)) + elif keytype == 'ssh-dss': + keys[host][keytype] = paramiko.DSSKey(data=base64.decodestring(key)) f.close() return keys @@ -75,7 +78,7 @@ try: print '*** WARNING: Unknown host key!' elif not keys[hostname].has_key(key.get_name()): print '*** WARNING: Unknown host key!' - elif keys[hostname][key.get_name()] != str(key): + elif keys[hostname][key.get_name()] != key: print '*** WARNING: Host key has changed!!!' sys.exit(1) else: -- cgit v1.2.3