from airflow import DAG
from airflow.operators.ssh_operator import SSHOperator
from datetime import datetime
default_args = {
'owner': 'airflow',
'depends_on_past': False,
'start_date': datetime(2024, 4, 29),
'email_on_failure': False,
'email_on_retry': False,
'retries': 1
}
dag = DAG('ssh_example', default_args=default_args, schedule_interval=None)
task_ssh = SSHOperator(
task_id='execute_ssh_command',
ssh_conn_id='ssh_default', # The name of the SSH connection to use, defined in Airflow Connections
command='echo "Hello, remote server"',
dag=dag
)