@@ -299,7 +299,8 @@ def open(ssh_username: str, ssh_server: None = None,
299299 ssh_key_file : Optional [Union [str , "Path" ]] = None ,
300300 ssh_password : Optional [str ] = None ,
301301 server_name : Optional [str ] = None , quiet : bool = False ,
302- thread_safe : bool = False ) -> LocalConnection :
302+ thread_safe : bool = False ,
303+ ssh_allow_agent : bool = False ) -> LocalConnection :
303304 ...
304305
305306 @overload
@@ -308,15 +309,17 @@ def open(ssh_username: str, ssh_server: str,
308309 ssh_key_file : Optional [Union [str , "Path" ]] = None ,
309310 ssh_password : Optional [str ] = None ,
310311 server_name : Optional [str ] = None , quiet : bool = False ,
311- thread_safe : bool = False ) -> SSHConnection :
312+ thread_safe : bool = False ,
313+ ssh_allow_agent : bool = False ) -> SSHConnection :
312314 ...
313315
314316 @staticmethod
315317 def open (ssh_username : str , ssh_server : Optional [str ] = "" ,
316318 ssh_key_file : Optional [Union [str , "Path" ]] = None ,
317319 ssh_password : Optional [str ] = None ,
318320 server_name : Optional [str ] = None , quiet : bool = False ,
319- thread_safe : bool = False ):
321+ thread_safe : bool = False ,
322+ ssh_allow_agent : bool = False ):
320323 """Initialize SSH or local connection.
321324
322325 Local connection is only a wrapper around os and shutil module methods
@@ -343,6 +346,8 @@ def open(ssh_username: str, ssh_server: Optional[str] = "",
343346 make connection object thread safe so it can be safely accessed
344347 from any number of threads, it is disabled by default to avoid
345348 performance penalty of threading locks
349+ ssh_allow_agent: bool
350+ allow the use of the ssh-agent to connect. Will disable ssh_key_file.
346351
347352 Warnings
348353 --------
@@ -354,7 +359,12 @@ def open(ssh_username: str, ssh_server: Optional[str] = "",
354359 pkey_file = ssh_key_file ,
355360 server_name = server_name , quiet = quiet )
356361 else :
357- if ssh_key_file :
362+ if ssh_allow_agent :
363+ c = SSHConnection (ssh_server , ssh_username ,
364+ allow_agent = ssh_allow_agent , line_rewrite = True ,
365+ server_name = server_name , quiet = quiet ,
366+ thread_safe = thread_safe )
367+ elif ssh_key_file :
358368 c = SSHConnection (ssh_server , ssh_username ,
359369 pkey_file = ssh_key_file , line_rewrite = True ,
360370 server_name = server_name , quiet = quiet ,
0 commit comments