Module Contents

class airflow.contrib.operators.ssh_operator.SSHOperator(ssh_hook=None, ssh_conn_id=None, remote_host=None, command=None, timeout=10, do_xcom_push=False, *args, **kwargs)[source]


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

  • ssh_hook (airflow.contrib.hooks.ssh_hook.SSHHook) – predefined ssh_hook to use for remote execution. Either ssh_hook or ssh_conn_id needs to be provided.

  • ssh_conn_id (str) – connection id from airflow Connections. ssh_conn_id will be ignored if ssh_hook is provided.

  • remote_host (str) – remote 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.

  • command (str) – command to execute on remote host. (templated)

  • timeout (int) – timeout (in seconds) for executing the command.

  • do_xcom_push (bool) – return the stdout which also get set in xcom by airflow platform

template_fields = ['command', 'remote_host'][source]
template_ext = ['.sh'][source]
execute(self, context)[source]