【问题标题】:Auto Authorize SSH Auth Requests on Travis CI在 Travis CI 上自动授权 SSH 身份验证请求
【发布时间】:2018-12-07 05:42:23
【问题描述】:

我正在我的构建中做一些事情以在我的 travis 测试中获得此输出。它挂起,因为我的测试无法接受或拒绝,并且测试失败:

The authenticity of host 'heroku.com (50.19.85.154)' can't be established.
RSA key fingerprint is 8b:48:5e:67:0e:c9:16:47:32:f2:87:0c:1blah.
Are you sure you want to continue connecting (yes/no)? 

我在 github.com 上遇到了类似的问题,但我改为只读 url。有没有办法让 travis 通过 ssh 自动授权任何身份验证请求,而不是为每个托管 git repo 的 x.com 处理这个问题?我可以通过以下方式在本地执行此操作:http://debuggable.com/posts/disable-strict-host-checking-for-git-clone:49896ff3-0ac0-4263-9703-1eae4834cda3 是否可以在 Travis 上设置类似的内容?

【问题讨论】:

    标签: travis-ci


    【解决方案1】:

    好吧,我想我明白了。一种选择是将这些行添加到您的 ~/.ssh/config 中的 before_script 中,如下所示:

    before_script:
      - echo -e "Host heroku.com\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config
      - echo -e "Host github.com\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config
    

    似乎可以解决问题。

    【讨论】:

    • 这确实是正确的做法。您是否有机会接受自己的答案(这样问题就不会再显示为“未回答”)?
    • 我将以上内容添加到我的 ~/.ssh/config 和我的 .travis.yml 文件中,但都不起作用,我错过了什么?
    • 这对我也不起作用;我使用了@Intentss 方法,效果很好。
    【解决方案2】:

    为此有新的travis 内置设置

    只需将其添加到您的配置中

    addons:
      ssh_known_hosts:
      - git.example.com
    

    https://docs.travis-ci.com/user/ssh-known-hosts/

    【讨论】:

      【解决方案3】:

      如果您在使用 travis-ci 时遇到此错误,可能是因为您的 gems 文件中的其中一个 gem 正在使用 github @git

      例如:

      gem 'pi_piper', :git => 'git@github.com:bguest/pi_piper.git', :branch => 'stub-driver'
      

      需要看起来像这样

      gem 'pi_piper', :git => 'https://github.com/bguest/pi_piper.git', :branch => 'stub-driver'
      

      【讨论】:

        【解决方案4】:

        一个更好的选择,而不是像公认的答案那样降低您的安全性,是让 travis 知道它实际上是一个受信任的主机。

        他们的文档对此进行了讨论:

        https://docs.travis-ci.com/user/ssh-known-hosts/#mitigations-and-workarounds

        基本上,从服务器获取公钥,并将其添加到 travis 上的 known_hosts 文件中,在 .travis.yml 中:

        install:
          - echo 'full_server_public_key_goes_here' >> $HOME/.ssh/known_hosts
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2018-06-22
          • 1970-01-01
          • 2011-09-27
          • 2017-05-28
          • 1970-01-01
          • 1970-01-01
          • 2018-09-02
          相关资源
          最近更新 更多