Avoid retrying an invalid SSH key_filename twice

Change-Id: I3700ef8ca8b82c8db3039b2d54a24f33208c0a82
This commit is contained in:
Federico Ressi 2020-11-05 07:20:32 +01:00
parent ad0881a25d
commit c8289a7f7e
1 changed files with 4 additions and 3 deletions

View File

@ -550,11 +550,12 @@ def ssh_connect(hostname, username=None, port=None, connection_interval=None,
key_filename=key_filename, key_filename=key_filename,
**parameters) **parameters)
except ValueError as ex: except ValueError as ex:
attempt.check_limits()
if (str(ex) == 'q must be exactly 160, 224, or 256 bits long' and if (str(ex) == 'q must be exactly 160, 224, or 256 bits long' and
key_filename): len(key_filename) > 1):
# Must try without the first key # Must try without the first key
LOG.debug("Retry connecting with the next key") LOG.debug(f"Retry connecting with the next key: {ex}")
key_filename = key_filename[1:] + [key_filename[0]] key_filename = key_filename[1:]
continue continue
else: else:
raise raise