From 944c8f694977a0f63e8a31891eed0e0c905b5fea Mon Sep 17 00:00:00 2001 From: jacob Date: Sun, 26 Apr 2009 23:44:28 +0000 Subject: [PATCH] Ansgar Wiechers points out that known_hosts (at least OpenSSH's) has grown a means of specifying port numbers, so we should support that. git-svn-id: svn://svn.tartarus.org/sgt/putty@8519 cda61777-01e9-0310-a592-d414129be87e --- contrib/kh2reg.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/contrib/kh2reg.py b/contrib/kh2reg.py index 4e881861..4872aec8 100755 --- a/contrib/kh2reg.py +++ b/contrib/kh2reg.py @@ -132,9 +132,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), ',') -- 2.11.0