簡體   English   中英

OpenShift Jenkins git clone 失敗:主機密鑰驗證失敗

[英]OpenShift Jenkins git clone fails: Host key verification failed

我嘗試在 Red Hat OpenShift 環境中的 Jenkins 中構建我的 Node JS(最新版本)應用程序,但它繼續失敗並在 Jenkins 日志中顯示以下消息:

Host key verification failed.
fatal: Could not read from remote repository.

經過進一步調查,發現 Jenkins 服務器無法從應用程序服務器克隆 repo:

[JENKINS_HOST test]\> git clone ssh://GUID@APP_HOST/~/git/sof.git
    Cloning into 'sof'...
    The authenticity of host 'APP_HOST (172.16.6.220)' can't be established.
    RSA key fingerprint is cf:ee:77:cb:0e:fc:02:d7:72:7e:ae:80:c0:90:88:a7.
Are you sure you want to continue connecting (yes/no)? yes
    Failed to add the host to the list of known hosts  (/var/lib/openshift/GUID/.ssh/known_hosts).
Permission denied (publickey,gssapi-keyex,gssapi-with-mic).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights and the repository exists.

我什至無法進入 Jenkins 主機上的.ssh目錄。

拿它來說,OpenShift 應用程序管理應該處理應用程序和 CI 主機之間的所有私鑰,但似乎不起作用。

有什么想法嗎?
我在整個網絡上進行了搜索,但特定於 OpenShift 的場景並不常見。

這可以使用自定義墨盒https://cartreflect-claytondev.rhcloud.com/reflect?github=smerrill/openshift-community-git-ssh墨盒創建腳本並設置 GIT_SSH 環境變量以在沒有嚴格主機的情況下運行 git-ssh關鍵檢查。

所以,

  1. 使用您的 Openshift 網絡控制台將墨盒安裝到您的 jenkins 應用程序(應用程序 / jenkins /“或者,查看您可以添加的墨盒的完整列表”,將鏈接放入“安裝您自己的墨盒”字段中)
  2. 通過 ssh 連接到 jenkins 應用程序:ssh @jenkins-.rhcloud.com
  3. cd ${OPENSHIFT_DATA_DIR}/git-ssh/
  4. ssh-keygen
    4.1. 設置密鑰文件 ./id_rsa
    4.2. 將密碼留空
    這將在 ${OPENSHIFT_DATA_DIR}/git-ssh/ 目錄中創建文件 id_rsa 和 id_rsa.pub
  5. 打印你的 id_rsa.pub: cat id_rsa.pub
  6. 復制 id_rsa.pub 的內容
  7. 在 Openshift Web 控制台中,轉到設置,添加新的公鑰
  8. 填寫密鑰名稱並將 id_rsa.pub 的內容粘貼到第二個字段中,按“創建”
  9. 重啟詹金斯應用

現在 git clone 肯定沒問題

如果您不需要提交將 協議更改為http並且您將不需要使用 ssh 密鑰,因為如果您的服務器允許並支持此協議,它應該是只讀的。

如果必須使用 ssh,則必須設置 ssh 密鑰。 沒有辦法“跳過”它。

如果有人來到這里並且他無法在 openshift 上克隆他的私人存儲庫。 不支持 SSH,也不支持 HTTP。 我有一個簡單的解決方案,效果很好。 使用 http 克隆並將您的令牌添加到 repo 鏈接,例如

git clone https://<token>@github.com/owner/repo.git

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM