@@ -41,8 +41,9 @@ class SSHClient(object):
4141 def __init__ (self , host ,
4242 user = None , password = None , port = None ,
4343 pkey = None , forward_ssh_agent = True ,
44- num_retries = DEFAULT_RETRIES , agent = None , timeout = 10 ,
45- proxy_host = None , proxy_port = 22 , channel_timeout = None ):
44+ num_retries = DEFAULT_RETRIES , agent = None ,
45+ allow_agent = True , timeout = 10 , proxy_host = None ,
46+ proxy_port = 22 , channel_timeout = None ):
4647 """Connect to host honouring any user set configuration in ~/.ssh/config \
4748 or /etc/ssh/ssh_config
4849
@@ -74,6 +75,10 @@ def __init__(self, host,
7475 connecting to local SSH agent to lookup keys with our own SSH agent \
7576 object.
7677 :type agent: :mod:`paramiko.agent.Agent`
78+ :param forward_ssh_agent: (Optional) Turn on SSH agent forwarding - \
79+ equivalent to `ssh -A` from the `ssh` command line utility. \
80+ Defaults to True if not set.
81+ :type forward_ssh_agent: bool
7782 :param proxy_host: (Optional) SSH host to tunnel connection through \
7883 so that SSH clients connects to self.host via client -> proxy_host -> host
7984 :type proxy_host: str
@@ -83,6 +88,9 @@ def __init__(self, host,
8388 :param channel_timeout: (Optional) Time in seconds before an SSH operation \
8489 times out.
8590 :type channel_timeout: int
91+ :param allow_agent: (Optional) set to False to disable connecting to \
92+ the SSH agent
93+ :type allow_agent: bool
8694 """
8795 ssh_config = paramiko .SSHConfig ()
8896 _ssh_config_file = os .path .sep .join ([os .path .expanduser ('~' ),
@@ -107,6 +115,7 @@ def __init__(self, host,
107115 self .pkey = pkey
108116 self .port = port if port else 22
109117 self .host = resolved_address
118+ self .allow_agent = allow_agent
110119 if agent :
111120 self .client ._agent = agent
112121 self .num_retries = num_retries
@@ -158,7 +167,8 @@ def _connect(self, client, host, port, sock=None, retries=1):
158167 client .connect (host , username = self .user ,
159168 password = self .password , port = port ,
160169 pkey = self .pkey ,
161- sock = sock , timeout = self .timeout )
170+ sock = sock , timeout = self .timeout ,
171+ allow_agent = self .allow_agent )
162172 except sock_gaierror , ex :
163173 logger .error ("Could not resolve host '%s' - retry %s/%s" ,
164174 self .host , retries , self .num_retries )
0 commit comments