BaseSSHClient

API documentation for common single host client functionality.

This class is abstract and contains functions that need to be implemented for each underlying SSH library.

class pssh.clients.base.single.BaseSSHClient(host, user=None, password=None, port=None, pkey=None, num_retries=3, retry_delay=5, allow_agent=True, timeout=None, proxy_host=None, _auth_thread_pool=True, identity_auth=True)
auth()
close_channel(channel)
copy_file(local_file, remote_file, recurse=False, sftp=None, _dir=None)
copy_remote_file(remote_file, local_file, recurse=False, sftp=None, encoding='utf-8')
disconnect()
execute(cmd, use_pty=False, channel=None)
get_exit_status(channel)
mkdir(sftp, directory, _parent_path=None)
open_session()
read_output(channel, timeout=None)
read_output_buffer(output_buffer, prefix=None, callback=None, callback_args=None, encoding='utf-8')

Read from output buffers and log to host_logger.

Parameters
  • output_buffer (iterator) – Iterator containing buffer

  • prefix (str) – String to prefix log output to host_logger with

  • callback (function) – Function to call back once buffer is depleted:

  • callback_args (tuple) – Arguments for call back function

read_stderr(channel, timeout=None)
run_command(command, sudo=False, user=None, use_pty=False, shell=None, encoding='utf-8', timeout=None)

Run remote command.

Parameters
  • command (str) – Command to run.

  • sudo (bool) – Run command via sudo as super-user.

  • user (str) – Run command as user via sudo

  • use_pty (bool) – Whether or not to obtain a PTY on the channel.

  • shell (str) – (Optional) Override shell to use to run command with. Defaults to login user’s defined shell. Use the shell’s command syntax, eg shell=’bash -c’ or shell=’zsh -c’.

  • encoding (str) – Encoding to use for output. Must be valid Python codec

Return type

(channel, host, stdout, stderr, stdin) tuple.

scp_recv(remote_file, local_file, recurse=False, sftp=None, encoding='utf-8')
scp_send(local_file, remote_file, recurse=False, sftp=None)
sftp_get(sftp, remote_file, local_file)
sftp_put(sftp, local_file, remote_file)
wait_finished(channel, timeout=None)
IDENTITIES = ('/home/docs/.ssh/id_rsa', '/home/docs/.ssh/id_dsa', '/home/docs/.ssh/identity', '/home/docs/.ssh/id_ecdsa', '/home/docs/.ssh/id_ed25519')