uranusjr commented on a change in pull request #15964:
URL: https://github.com/apache/airflow/pull/15964#discussion_r635874891



##########
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:
       As I mentioned in the linked issue, it may be easier to do it this way:
   
   ```python
   client_host_keys.add(self.remote_host, 'ssh-rsa', self.host_key)
   if self.port:
       client_host_keys.add(f"{self.remote_host}:{self.port}", 'ssh-rsa', 
self.host_key)
   ```




-- 
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]


Reply via email to