Skip to content

Commit

Permalink
SSHHook: Using correct hostname for host_key when using non-default s…
Browse files Browse the repository at this point in the history
…sh port (#15964)
  • Loading branch information
freget committed Jul 3, 2021
1 parent ffe8fab commit a2dc01b
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion airflow/providers/ssh/hooks/ssh.py
Expand Up @@ -241,7 +241,12 @@ def get_conn(self) -> paramiko.SSHClient:
else:
if self.host_key is not None:
client_host_keys = client.get_host_keys()
client_host_keys.add(self.remote_host, self.host_key.get_name(), self.host_key)
if self.port == SSH_PORT:
client_host_keys.add(self.remote_host, self.host_key.get_name(), self.host_key)
else:
client_host_keys.add(
f"[{self.remote_host}]:{self.port}", self.host_key.get_name(), self.host_key
)
else:
pass # will fallback to system host keys if none explicitly specified in conn extra

Expand Down

0 comments on commit a2dc01b

Please sign in to comment.