freget commented on a change in pull request #15964:
URL: https://github.com/apache/airflow/pull/15964#discussion_r635935445
##########
File path: airflow/providers/ssh/hooks/ssh.py
##########
@@ -218,7 +218,8 @@ 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, 'ssh-rsa',
self.host_key)
+ remote_host = f"[{self.remote_host}]:{self.port}" if self.port
!= SSH_PORT else self.remote_host
+ client_host_keys.add(remote_host, 'ssh-rsa', self.host_key)
Review comment:
I'm not convinced it is a good idea to add the host key without port
unconditionally. At least in theory it might be possible that there is one
server listening on the default port and another one on self.port. Those
servers could have different public keys.
However, it might be more clear to have that explicit branch instead of the
inline if. I will adjust the PR accordingly.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]