This is an automated email from the ASF dual-hosted git repository.
potiuk pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new a2dc01b SSHHook: Using correct hostname for host_key when using
non-default ssh port (#15964)
a2dc01b is described below
commit a2dc01b34590fc7830bdb76fea653e1a0ebecbd3
Author: freget <[email protected]>
AuthorDate: Sat Jul 3 16:53:28 2021 +0200
SSHHook: Using correct hostname for host_key when using non-default ssh
port (#15964)
---
airflow/providers/ssh/hooks/ssh.py | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/airflow/providers/ssh/hooks/ssh.py
b/airflow/providers/ssh/hooks/ssh.py
index 8489932..a8994bd 100644
--- a/airflow/providers/ssh/hooks/ssh.py
+++ b/airflow/providers/ssh/hooks/ssh.py
@@ -241,7 +241,12 @@ class SSHHook(BaseHook):
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