Skip to content

Commit

Permalink
Handle legacy ssh servers that don't use rsa-sha2
Browse files Browse the repository at this point in the history
e.g. orcinus & optimum in Mar-2022

re: issue #96
  • Loading branch information
douglatornell committed Mar 9, 2022
1 parent 28f2ba4 commit dc059f6
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions nowcast/ssh_sftp.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,19 @@ def ssh(host, key_filename, ssh_config_file="~/.ssh/config"):
with open(os.path.expanduser(ssh_config_file)) as f:
ssh_config.parse(f)
host = ssh_config.lookup(host)
ssh_client.connect(
host["hostname"], username=host["user"], key_filename=os.fspath(key_filename),
allow_agent=False, look_for_keys=False,
)
try:
# Modern ssh server that uses a rsa-sha2 algorithm; e.g. arbutus and graham
ssh_client.connect(
host["hostname"], username=host["user"], key_filename=os.fspath(key_filename),
allow_agent=False, look_for_keys=False,
)
except paramiko.ssh_exception.SSHException:
# Legacy ssh server that doesn't use rsa-sha2 algorithms; e.g. orcinus and optimum
ssh_client.connect(
host["hostname"], username=host["user"], key_filename=os.fspath(key_filename),
allow_agent=False, look_for_keys=False,
disabled_algorithms={'pubkeys': ['rsa-sha2-512', 'rsa-sha2-256']},
)
return ssh_client


Expand Down

0 comments on commit dc059f6

Please sign in to comment.