You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2019/09/16 10:10:14 UTC

[GitHub] [airflow] kaxil commented on a change in pull request #6104: [AIRFLOW-4574] allow providing private_key in SSHHook

kaxil 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_r324596232
 
 

 ##########
 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:
   We should make them mutually exclusive and error if both are passed.

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


With regards,
Apache Git Services