pyinfra.api.connectors.ssh module¶
-
pyinfra.api.connectors.ssh.
connect
(state, host, **kwargs)¶ Connect to a single host. Returns the SSH client if succesful. Stateless by design so can be run in parallel.
-
pyinfra.api.connectors.ssh.
put_file
(state, host, file_io, remote_file, sudo=False, sudo_user=None, su_user=None, print_output=False)¶ Upload file-ios to the specified host using SFTP. Supports uploading files with sudo by uploading to a temporary directory then moving & chowning.
-
pyinfra.api.connectors.ssh.
run_shell_command
(state, host, command, sudo=False, sudo_user=None, su_user=None, preserve_sudo_env=False, get_pty=False, env=None, timeout=None, print_output=False)¶ Execute a command on the specified host.
Parameters: - state (
pyinfra.api.State
obj) – state object for this command - hostname (string) – hostname of the target
- command (string) – actual command to execute
- sudo (boolean) – whether to wrap the command with sudo
- sudo_user (string) – user to sudo to
- get_pty (boolean) – whether to get a PTY before executing the command
- env (dict) – envrionment variables to set
- timeout (int) – timeout for this command to complete before erroring
Returns: (exit_code, stdout, stderr) stdout and stderr are both lists of strings from each buffer.
Return type: tuple
- state (