diff --git a/tsshbatch.py b/tsshbatch.py index ea83a1a..8209532 100755 --- a/tsshbatch.py +++ b/tsshbatch.py @@ -20,7 +20,7 @@ CMDINCL = PROGENV + "CMDS" HOSTINCL = PROGENV + "HOSTS" -CVSID = "$Id: tsshbatch.py,v 1.226 2016/01/18 22:19:30 tundra Exp $" +CVSID = "$Id: tsshbatch.py,v 1.227 2016/01/18 22:41:05 tundra Exp $" VERSION = CVSID.split()[2] CPRT = "(c)" PROGDATE = "2011-2016" @@ -705,6 +705,9 @@ def SSH_GetConfig(filename): + # NOTE: We only support the "IdentityFile" and "HostName" + # configuration directives here. + retval = {} sshconfig = paramiko.SSHConfig() try: @@ -723,7 +726,17 @@ for host in sshconfig.get_hostnames(): if host != "*": cfgentry = sshconfig.lookup(host) - retval[host] = [cfgentry[CFGKEYID], cfgentry[CFGREALHOST]] + output = [] + + keyfiles = [] + if CFGKEYID in cfgentry: + keyfiles = cfgentry[CFGKEYID] + + realhost = host + if CFGREALHOST in cfgentry: + realhost = cfgentry[CFGREALHOST] + + retval[host] = [keyfiles, realhost] return retval