@@ -62,9 +62,17 @@ def __init__(self, host,
6262 :param user: (Optional) User to login as. Defaults to logged in user or \
6363 user from ~/.ssh/config if set
6464 :type user: str
65- :raises: ssh_client.AuthenticationException on authentication error
66- :raises: ssh_client.UnknownHostException on DNS resolution error
67- :raises: ssh_client.ConnectionErrorException on error connecting"""
65+ :param password: (Optional) Password to use for login. Defaults to\
66+ no password
67+ :type password: str
68+ :param port: (Optional) Port number to use for SSH connection. Defaults\
69+ to None which uses SSH default
70+ :type port: int
71+ :param pkey: (Optional) Client's private key to be used to connect with
72+ :type pkey: :mod:`paramiko.PKey`
73+ :raises: AuthenticationException on authentication error
74+ :raises: UnknownHostException on DNS resolution error
75+ :raises: ConnectionErrorException on error connecting"""
6876 ssh_config = paramiko .SSHConfig ()
6977 _ssh_config_file = os .path .sep .join ([os .path .expanduser ('~' ),
7078 '.ssh' ,
@@ -224,23 +232,36 @@ def __init__(self, hosts,
224232 :param port: (Optional) Port number to use for SSH connection. Defaults\
225233 to None which uses SSH default
226234 :type port: int
235+ :param pkey: (Optional) Client's private key to be used to connect with
236+ :type pkey: :mod:`paramiko.PKey`
227237 :param pool_size: (Optional) Greenlet pool size. Controls on how many\
228238 hosts to execute tasks in parallel. Defaults to 10
229239 :type pool_size: int
230- :raises: paramiko. AuthenticationException on authentication error
231- :raises: ssh_client. UnknownHostException on DNS resolution error
232- :raises: ssh_client. ConnectionErrorException on error connecting
240+ :raises: AuthenticationException on authentication error
241+ :raises: UnknownHostException on DNS resolution error
242+ :raises: ConnectionErrorException on error connecting
233243
234244 **Example**
235245
236- >>> client = ParallelSSHClient(['myhost1', 'myhost2'])
246+ >>> from pssh import ParallelSSHClient, AuthenticationException,\
247+ UnknownHostException, ConnectionErrorException
248+ >>> try:
249+ >>> ... client = ParallelSSHClient(['myhost1', 'myhost2'])
250+ >>> except (AuthenticationException, UnknownHostException, ConnectionErrorException):
251+ >>> ... return
237252 >>> cmds = client.exec_command('ls -ltrh /tmp/aasdfasdf', sudo = True)
238253 >>> output = [client.get_stdout(cmd) for cmd in cmds]
239254 [myhost1] ls: cannot access /tmp/aasdfasdf: No such file or directory
240255 [myhost2] ls: cannot access /tmp/aasdfasdf: No such file or directory
241256 >>> print output
242257 [{'myhost1': {'exit_code': 2}}, {'myhost2': {'exit_code': 2}}]
243258
259+ **Example with specified private key**
260+
261+ >>> import paramiko
262+ >>> client_key = paramiko.RSAKey.from_private_key_file('user.key')
263+ >>> client = ParallelSSHClient(['myhost1', 'myhost2'], pkey=client_key)
264+
244265 .. note ::
245266
246267 **Connection persistence**
0 commit comments