Skip to content

Commit ffcbf8d

Browse files
committed
Added SSH agent forward flag to ParallelSSHClient
1 parent 4866cee commit ffcbf8d

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

pssh.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,7 @@ class ParallelSSHClient(object):
273273

274274
def __init__(self, hosts,
275275
user=None, password=None, port=None, pkey=None,
276+
forward_ssh_agent=True,
276277
pool_size=10):
277278
"""
278279
:param hosts: Hosts to connect to
@@ -366,6 +367,7 @@ def __init__(self, hosts,
366367
self.hosts = hosts
367368
self.user = user
368369
self.password = password
370+
self.forward_ssh_agent = forward_ssh_agent
369371
self.port = port
370372
self.pkey = pkey
371373
# To hold host clients
@@ -407,7 +409,8 @@ def _exec_command(self, host, *args, **kwargs):
407409
if not self.host_clients[host]:
408410
self.host_clients[host] = SSHClient(host, user=self.user,
409411
password=self.password,
410-
port=self.port, pkey=self.pkey)
412+
port=self.port, pkey=self.pkey,
413+
forward_ssh_agent=self.forward_ssh_agent)
411414
return self.host_clients[host].exec_command(*args, **kwargs)
412415

413416
def get_stdout(self, greenlet, return_buffers=False):
@@ -480,7 +483,8 @@ def _copy_file(self, host, local_file, remote_file):
480483
if not self.host_clients[host]:
481484
self.host_clients[host] = SSHClient(host, user=self.user,
482485
password=self.password,
483-
port=self.port)
486+
port=self.port, pkey=self.pkey,
487+
forward_ssh_agent=self.forward_ssh_agent)
484488
return self.host_clients[host].copy_file(local_file, remote_file)
485489

486490

0 commit comments

Comments
 (0)