openspug / spug

开源运维平台:面向中小型企业设计的轻量级无Agent的自动化运维平台,整合了主机管理、主机批量执行、主机在线终端、文件在线上传下载、应用发布部署、在线任务计划、配置中心、监控、报警等一系列功能。
https://spug.cc
GNU Affero General Public License v3.0
10.33k stars 2.08k forks source link

Bug: 首次与 Git 远程主机 ssh 认证的问题 #534

Closed zhanglianxin closed 2 years ago

zhanglianxin commented 2 years ago

Spug 版本: v3.2.3

问题重现步骤

当以下情况时:

会出现: Exception: Cmd('git') failed due to: exit code(128) cmdline: git clone -v git@github.com:xxx/xxx.git /repos/2 stderr: 'Cloning into '/repos/2'... Host key verification failed. fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. ' host key 认证失败。

期望的结果

建议:在不影响主机本身 ssh_config 配置的情况下,https://github.com/openspug/spug/blob/376f192f6e16f1514c277a6c586aed8f96693191/spug_api/libs/gitlib.py#L100 加入禁用 host key 检查的选项,参考 https://unix.stackexchange.com/a/33273

zhanglianxin commented 2 years ago

And GitPython 文档中这样描述:

StrictHostKeyChecking=no is used to avoid prompts asking to save the hosts key to ~/.ssh/known_hosts, which happens in case you run this as daemon.

vapao commented 2 years ago

非常感谢