【问题标题】:How to accept ssh host verification in jenkins ssh agent如何在 jenkins ssh 代理中接受 ssh 主机验证
【发布时间】:2018-10-18 02:19:15
【问题描述】:

参考下面的詹金斯管道脚本

sshagent(['sshuser']) {
    sh "git clone ssh://git@git.local.com/test/test-commit.git"         
}

我总是在 jenkins 中获得以下日志

Cloning into 'test-commit'...
Host key verification failed.
fatal: Could not read from remote repository.

尝试了一些技巧来自动接受主机验证,但都失败了,非常沮丧。

【问题讨论】:

  • 你是如何解决这个问题的?您是否使用下面的答案并绕过检查?

标签: jenkins ssh-agent


【解决方案1】:

如果您主要关心的是 git,您可以使用 GIT_SSH_COMMAND 环境变量。它允许您注入 ssh 选项:

stage('My git stage') {
    environment {
        GIT_SSH_COMMAND = "ssh -o StrictHostKeyChecking=no"
    }
    steps {
        sshagent(['sshuser']) {
            sh "git clone ssh://git@git.local.com/test/test-commit.git"         
        }
    }
}

请注意,这会带来一些安全问题。你可能想调查一下:https://www.symantec.com/connect/articles/ssh-host-key-protection

【讨论】:

  • 我试过这个解决方案,但我仍然得到问题中定义的错误:Host key verification failed. fatal: Could not read from remote repository.
猜你喜欢
  • 2017-09-10
  • 2018-12-04
  • 2020-07-15
  • 2014-04-03
  • 2014-10-23
  • 2015-07-09
  • 2018-12-16
  • 2021-03-20
  • 2023-03-06
相关资源
最近更新 更多