【问题标题】:Can't find SSH keys settings under travis project settings在 travis 项目设置下找不到 SSH 密钥设置
【发布时间】:2020-04-22 11:29:17
【问题描述】:

我的 CI 项目依赖于另一个私有仓库。所以我参考document上传私钥使用

➜ travis sshkey --upload ~/.ssh/id_travis_rsa --pro
Updating ssh key for Jeff-Tian/uni-sso with key from /Users/tianjef/.ssh/id_travis_rsa

Current SSH key: key for clone k8s-config
Finger print:    65:25:66:26:4d:5d:9f:ac:25:ba:ea:be:c4:d5:e3:5f

从上面我仔细检查了指纹,并与 github ssh 密钥进行了比较:

它们是匹配的。

但是,travis 构建仍然失败:

(https://travis-ci.com/github/Jeff-Tian/uni-sso/builds/161350192)

$ git clone git@github.com:Jeff-Tian/k8s-config.git ${HOME}/k8s-config
Cloning into '/home/travis/k8s-config'...
Warning: Permanently added the RSA host key for IP address '140.82.114.4' to the list of known hosts.
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
The command "git clone git@github.com:Jeff-Tian/k8s-config.git ${HOME}/k8s-config" failed and exited with 128 during .

然后我检查了 travis 设置上的设置,找不到 ssh 密钥设置窗格:

帮助:

哪里出了问题?是 Travis CI 的错误吗?

【问题讨论】:

    标签: travis-ci ssh-keys


    【解决方案1】:

    似乎 ssh 密钥配置仅适用于 private 存储库。

    这里的问题是主 repo 是 public,但是在部署它时,需要下载 private repo。 official document 未涵盖此场景。

    解决方法是通过https 而不是ssh 切换复制私人 repo,因此无需上传ssh 密钥。

    通过在设置中设置GH_TOKEN,然后将该令牌写入.netrc 文件。然后使用 https 复制 private 存储库即可:

    .travis.yml:

      - echo -e "machine github.com\n  login $GH_TOKEN" > ~/.netrc
      - git clone https://github.com/Jeff-Tian/k8s-config.git ${HOME}/k8s-config
    

    【讨论】:

      猜你喜欢
      • 2020-03-01
      • 1970-01-01
      • 2019-09-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-06-07
      • 2010-09-10
      • 2023-03-21
      相关资源
      最近更新 更多