@@ -299,7 +299,8 @@ def open(ssh_username: str, ssh_server: None = None,
299
299
ssh_key_file : Optional [Union [str , "Path" ]] = None ,
300
300
ssh_password : Optional [str ] = None ,
301
301
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 :
303
304
...
304
305
305
306
@overload
@@ -308,15 +309,17 @@ def open(ssh_username: str, ssh_server: str,
308
309
ssh_key_file : Optional [Union [str , "Path" ]] = None ,
309
310
ssh_password : Optional [str ] = None ,
310
311
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 :
312
314
...
313
315
314
316
@staticmethod
315
317
def open (ssh_username : str , ssh_server : Optional [str ] = "" ,
316
318
ssh_key_file : Optional [Union [str , "Path" ]] = None ,
317
319
ssh_password : Optional [str ] = None ,
318
320
server_name : Optional [str ] = None , quiet : bool = False ,
319
- thread_safe : bool = False ):
321
+ thread_safe : bool = False ,
322
+ ssh_allow_agent : bool = False ):
320
323
"""Initialize SSH or local connection.
321
324
322
325
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] = "",
343
346
make connection object thread safe so it can be safely accessed
344
347
from any number of threads, it is disabled by default to avoid
345
348
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.
346
351
347
352
Warnings
348
353
--------
@@ -354,7 +359,12 @@ def open(ssh_username: str, ssh_server: Optional[str] = "",
354
359
pkey_file = ssh_key_file ,
355
360
server_name = server_name , quiet = quiet )
356
361
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 :
358
368
c = SSHConnection (ssh_server , ssh_username ,
359
369
pkey_file = ssh_key_file , line_rewrite = True ,
360
370
server_name = server_name , quiet = quiet ,
0 commit comments