Prevent adding port twice when adding entry in known hosts

Check hostname value inside remote_host dictionary to find out ':'. In that case don't append port
This commit is contained in:
abednarik 2015-11-30 15:37:51 -03:00 committed by rallytime
parent 14e94b3593
commit 3a0e19debb

View file

@ -919,7 +919,7 @@ def set_known_host(user=None,
if key:
remote_host = {'hostname': hostname, 'enc': enc, 'key': key}
if hash_known_hosts or port == DEFAULT_SSH_PORT:
if hash_known_hosts or port == DEFAULT_SSH_PORT or ':' in remote_host['hostname']:
line = '{hostname} {enc} {key}\n'.format(**remote_host)
else:
remote_host['port'] = port