I'm trying to connect to an ec2 instance with airflow using the SSHOperator but my dag fails with the following error message:
[2020-05-24 06:17:04,191] {base_task_runner.py:98} INFO - Subtask: File "/usr/local/lib/python3.6/site-packages/airflow/contrib/operators/ssh_operator.py", line 146, in execute
[2020-05-24 06:17:04,191] {base_task_runner.py:98} INFO - Subtask: raise AirflowException("SSH operator error: {0}".format(str(e)))
[2020-05-24 06:17:04,191] {base_task_runner.py:98} INFO - Subtask: airflow.exceptions.AirflowException: SSH operator error: 'NoneType' object has no attribute 'exec_command'
Here's my source code:
from airflow.contrib.operators.ssh_operator import SSHOperator
...
t1 = BashOperator(
task_id='print_date',
bash_command='date',
dag=DAG)
t2 = SSHOperator(
ssh_conn_id='my_ec2_connection',
task_id='ssh_operator',
command='ls',
dag=DAG)
t1 >> t2
I've setup the pem file using ssh connection in the UI and also did the ssh-add of the pem key.