This package provides operators, hooks, and sensors for interacting with SSH, SFTP, and SCP within Apache Airflow DAGs. It enables automation of tasks on remote servers via SSH protocol, including command execution and file transfers, supporting various authentication methods. The current version is 4.3.3, and its release cadence is tied to the broader Apache Airflow provider release schedule, with frequent updates.
pip install apache-airflow-providers-sshVerified import paths — ran on the pinned version, not inferred.
This example demonstrates a basic DAG using the `SSHOperator` to connect to a remote server and execute a shell command. Before running, configure an 'SSH' connection in your Airflow UI (Admin -> Connections) with `Conn Id` as `ssh_default`, providing `Host`, `Login (Username)`, and `Port`. For authentication, you can specify `Password`, `Key File` path, or `Private Key` content in the 'Extra' field as a JSON object (e.g., `{"key_file": "/path/to/your/key.pem"}`).
Review changelog for 4.0.0 and update code to use recommended methods and parameters (e.g., `conn_timeout` instead of `timeout`, `hook` attribute instead of `get_hook()`). Ensure your Airflow environment is on version 2.9.0 or higher.
Upgrade your Apache Airflow installation to at least 2.11.0 and ensure your Python environment is 3.10 or newer for provider versions 4.2.0+.
Explicitly configure `no_host_key_check` and `allow_host_key_change` parameters in your Airflow SSH connection (often via 'Extra' JSON) to match your security policy. Consider using `host_key` in the connection extra to pin a specific host key.
Ensure the provider package is installed in the same Python environment as your Airflow installation. Restart Airflow scheduler and webserver components. Verify installation using `airflow providers list` or `pip list` in your Airflow environment.
Update your DAG definitions to use the `schedule` parameter instead of `schedule_interval`. For example, change `schedule_interval=None` to `schedule=None` or `schedule='@daily'` to `schedule='@daily'`. Also, update your import statements from `from airflow import DAG` to `from airflow.sdk import DAG`.
Install the package using 'pip install apache-airflow-providers-ssh'.
Increase the 'conn_timeout' parameter in the SSH connection settings.
Add 'apache-airflow-providers-ssh' to the 'requirements.txt' file and update the MWAA environment.
Ensure 'apache-airflow-providers-ssh' is listed in 'requirements.txt' and the MWAA environment is updated.
Increase the `cmd_timeout` parameter in your `SSHOperator` or `SSHHook` definition, or set it to `None` for no timeout, based on the expected duration of your remote command. For connection issues, adjust `conn_timeout`. Example: `SSHOperator(task_id='my_ssh_task', ssh_conn_id='ssh_default', command='long_running_script.sh', cmd_timeout=300)` or `SSHHook(ssh_conn_id='ssh_default', cmd_timeout=None)`.