SSHOperator

SSH

SSHOperator to execute commands on given remote host using the ssh_hook.

View on GitHub

Last Updated: May. 7, 2021

Access Instructions

Install the SSH provider package into your Airflow environment.

Import the module into your DAG file and instantiate it with your desired params.

Parameters

ssh_hookairflow.providers.ssh.hooks.ssh.SSHHookpredefined ssh_hook to use for remote execution. Either ssh_hook or ssh_conn_id needs to be provided.
ssh_conn_idstrconnection id from airflow Connections. ssh_conn_id will be ignored if ssh_hook is provided.
remote_hoststrremote host to connect (templated) Nullable. If provided, it will replace the remote_host which was defined in ssh_hook or predefined in the connection of ssh_conn_id.
commandstrcommand to execute on remote host. (templated)
timeoutinttimeout (in seconds) for executing the command. The default is 10 seconds.
environmentdicta dict of shell environment variables. Note that the server will reject them silently if AcceptEnv is not set in SSH config.
get_ptyboolrequest a pseudo-terminal from the server. Set to True to have the remote process killed upon task timeout. The default is False but note that get_pty is forced to True when the command starts with sudo.

Documentation

SSHOperator to execute commands on given remote host using the ssh_hook.

Was this page helpful?