@@ -69,7 +69,8 @@ class SSHClient(object):
6969
7070 def __init__ (self , host ,
7171 user = None , password = None , port = None ,
72- pkey = None , forward_ssh_agent = True ):
72+ pkey = None , forward_ssh_agent = True ,
73+ _agent = None ):
7374 """Connect to host honouring any user set configuration in ~/.ssh/config \
7475 or /etc/ssh/ssh_config
7576
@@ -90,6 +91,11 @@ def __init__(self, host,
9091 equivalent to `ssh -A` from the `ssh` command line utility.
9192 Defaults to True if not set.
9293 :type forward_ssh_agent: bool
94+ :param _agent: (Optional) Override SSH agent object with the provided. \
95+ This allows for overriding of the default paramiko behaviour of \
96+ connecting to local SSH agent to lookup keys with our own SSH agent.
97+ Only really useful for testing, hence the internal variable prefix.
98+ :type _agent: :mod:`paramiko.agent.Agent`
9399 :raises: :mod:`pssh.AuthenticationException` on authentication error
94100 :raises: :mod:`pssh.UnknownHostException` on DNS resolution error
95101 :raises: :mod:`pssh.ConnectionErrorException` on error connecting"""
@@ -120,6 +126,8 @@ def __init__(self, host,
120126 self .pkey = pkey
121127 self .port = port if port else 22
122128 self .host = resolved_address
129+ if _agent :
130+ self .client ._agent = _agent
123131 self ._connect ()
124132
125133 def _connect (self , retries = 1 ):
0 commit comments