Skip to main content
 首页 » 编程设计

python之如何在 Airflow 中通过 SSH 和运行 PythonOperator

2025年02月15日12xiaohuochai

有没有办法通过 ssh 连接到服务器并使用 Airflow 运行 PythonOperator?我看起来像 SSHExecuteOperator 但不是执行 bash 命令而是执行 python 可调用。

请您参考如下方法:

它的ssh隐私问题

  1. 转到您的主机 ssh 服务器并运行 ssh-keygen -t rsa 并一直按回车键
  2. 您将获得 2 个 rsa 文件。将该文件复制到 airflow env 并复制其完整路径
  3. The Just add the below in your connection from the airflow UI

     {"key_file": "/usr/local/airflow/.ssh/id_rsa.pub", "no_host_key_check": true} 
    

    重新编译DAG并运行