Airflow SSH 操作员错误:遇到 RSA 密钥,应为 OPENSSH 密钥
Posted
技术标签:
【中文标题】Airflow SSH 操作员错误:遇到 RSA 密钥,应为 OPENSSH 密钥【英文标题】:Airflow SSH Operator Error: Encountered RSA key, expected OPENSSH key 【发布时间】:2020-11-30 13:54:57 【问题描述】:在 Airflow:1.10.10 上运行的气流 DAG 随机失败,并带有以下回溯: Airflow 在 docker swarm 上运行,并且相同的 ssh RSA 密钥用于 Airflow DAG 中使用的大多数连接。很少有 DAG 随机失败并带有以下提到的回溯:
SSH 私钥是使用默认设置的 ssh-keygen 生成的 RSA 密钥。
追溯:
[2020-11-21 18:30:38,821] taskinstance.py:1145 ERROR - SSH operator error: encountered RSA key, expected OPENSSH key
Traceback (most recent call last):
File "/home/airflow/.local/lib/python2.7/site-packages/airflow/models/taskinstance.py", line 983, in _run_raw_task
result = task_copy.execute(context=context)
File "/home/airflow/.local/lib/python2.7/site-packages/airflow/contrib/operators/ssh_operator.py", line 177, in execute
raise AirflowException("SSH operator error: 0".format(str(e)))
AirflowException: SSH operator error: encountered RSA key, expected OPENSSH key
[2020-11-21 18:30:38,822] taskinstance.py:1168 INFO - Marking task as UP_FOR_RETRY
[2020-11-21 18:30:43,763] logging_mixin.py:112 INFO - [2020-11-21 18:30:43,763] local_task_job.py:103 INFO - Task exited with return code 1
DAG 代码:
#!/usr/bin/env python2.7
from datetime import timedelta, datetime
import airflow
from airflow import DAG
from airflow.contrib.operators.ssh_operator import SSHOperator
import pendulum
local_timezone = pendulum.timezone("Asia/Calcutta")
default_args = dict(
depends_on_past=False,
start_date=datetime(2020,10,20,tzinfo=local_timezone),
retries=1,
retry_delay=timedelta(minutes=5),
)
dag = DAG(dag_id='queue_cleanup',
default_args=default_args,
schedule_interval='@daily',
dagrun_timeout=timedelta(seconds=120),
catchup=False,
tags=['maintenance'])
print(dag.timezone)
t1_bash = """
sh /home/user/default_jobs/chk_status.sh
"""
t1 = SSHOperator(
ssh_conn_id='conn_id',
task_id='ssh_default_queue_cleanup',
command=t1_bash,
dag=dag)
连接 ID 额外的 Json:
"key_file": "/etc/id_rsa",
"timeout": "10",
"compress": "false",
"no_host_key_check": "true",
"allow_host_key_change": "false"
【问题讨论】:
【参考方案1】:已解决。问题在于我们尝试使用 ssh 连接 ID 连接的目标节点。用户帐户已过期
chage -l user --> 显示用户帐号已过期。
激活用户帐户后一切正常。
【讨论】:
以上是关于Airflow SSH 操作员错误:遇到 RSA 密钥,应为 OPENSSH 密钥的主要内容,如果未能解决你的问题,请参考以下文章
Airflow:如何从不同的服务器进行 SSH 和运行 BashOperator
SSH登录时“no matching host key type found. Their offer: ssh-rsa,ssh-dss“的错误解决方法