freget commented on a change in pull request #15964:
URL: https://github.com/apache/airflow/pull/15964#discussion_r637205628
##########
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:
In line 196 the port is set to SSH_PORT if it is None:
self.port = self.port or SSH_PORT
Hence, checking for `self.port is None` is always false. Your suggestion
results in adding both `self.remote_host` and
`f"{[self.remote_host}]:{self.port}"` in most cases. Adding the latter for the
standard port is not required according to the OpenSSH documentation
(https://en.wikibooks.org/wiki/OpenSSH/Client_Configuration_Files#~/.ssh/known_hosts).
As Paramiko expects the strings according to the OpenSSH format, we would just
be adding a redundant, never used entry.
--
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]