mik-laj commented on a change in pull request #6104: [AIRFLOW-4574] allow 
providing private_key in SSHHook
URL: https://github.com/apache/airflow/pull/6104#discussion_r324603424
 
 

 ##########
 File path: airflow/contrib/hooks/ssh_hook.py
 ##########
 @@ -160,24 +169,27 @@ def get_conn(self):
                              'against Man-In-The-Middle attacks')
             # Default is RejectPolicy
             client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
-
-        if self.password and self.password.strip():
-            client.connect(hostname=self.remote_host,
-                           username=self.username,
-                           password=self.password,
-                           key_filename=self.key_file,
-                           timeout=self.timeout,
-                           compress=self.compress,
-                           port=self.port,
-                           sock=self.host_proxy)
-        else:
-            client.connect(hostname=self.remote_host,
-                           username=self.username,
-                           key_filename=self.key_file,
-                           timeout=self.timeout,
-                           compress=self.compress,
-                           port=self.port,
-                           sock=self.host_proxy)
+        connect_kwargs = dict(
+            hostname=self.remote_host,
+            username=self.username,
+            timeout=self.timeout,
+            compress=self.compress,
+            port=self.port,
+            sock=self.host_proxy
+        )
+
+        if self.password:
+            password = self.password.strip()
+            connect_kwargs.update(password=password)
+
+        # prefer pkey over key_filename when both are given
 
 Review comment:
   I agree with @kaxil 

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to