X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=blobdiff_plain;f=contrib%2Fkh2reg.py;h=503dd6e34fc291640d56d9050de5c5f18c8826b6;hb=ced3a46c3f993e6257ec25337395d0c6bf6dbf59;hp=4e88186106055696cdecc5457e3c4df25a0c31f1;hpb=54c3773c91c600f703cce8b4c949db2618c1c9ff;p=PuTTY.git diff --git a/contrib/kh2reg.py b/contrib/kh2reg.py index 4e881861..503dd6e3 100755 --- a/contrib/kh2reg.py +++ b/contrib/kh2reg.py @@ -1,6 +1,5 @@ #! /usr/bin/env python -# $Id$ # Convert OpenSSH known_hosts and known_hosts2 files to "new format" PuTTY # host keys. # usage: @@ -132,9 +131,13 @@ for line in fileinput.input(args): sys.stderr.write("Skipping hashed hostname '%s'\n" % host) continue else: - # Slightly bizarre key format: 'type@port:hostname' - # As far as I know, the input never specifies a port. - port = 22 + m = re.match (r"\[([^]]*)\]:(\d*)$", host) + if m: + (host, port) = m.group(1,2) + port = int(port) + else: + port = 22 + # Slightly bizarre output key format: 'type@port:hostname' # XXX: does PuTTY do anything useful with literal IP[v4]s? key = keytype + ("@%d:%s" % (port, host)) value = string.join (map (longtohex, magicnumbers), ',')