日本免费高清视频-国产福利视频导航-黄色在线播放国产-天天操天天操天天操天天操|www.shdianci.com

學無先后,達者為師

網站首頁 編程語言 正文

解決GitLab中使用SSH的git clone總是提示輸入密碼且任何密碼都不對

作者:暗諾星刻 更新時間: 2022-05-11 編程語言

解決GitLab中使用SSH的git clone總是提示輸入密碼且任何密碼都不對

??筆者最近在新 Linux 中安裝 GitLab 后,發現一個詭異的事情。當配置完管理員賬號、SSH 密鑰之后、開啟防火墻端口號、在 GitLab 新建倉庫 test 等等之后,筆者嘗試在遠程客戶端 Windows 上使用 git clone 來 clone 這個在 GitLab 上的倉庫,使用的是 SSH 協議。但無論 clone 的 URL 是否正確,終端提示輸入密碼,且輸入任何密碼都不對。完整提示信息內容如下:

筆者報錯時的運行環境:

  • GitLab:gitlab-ee-14.3.6-ee.0.el8.x86_64

  • GitLab 上的 Linux:CentOS Stream 8 x86_64

  • 遠程客戶端 Windows:Windows 10 教育版

$ git clone git@xxx.xxx.xxx.xxx:XXX/test.git
Cloning into 'test'...
/c/Users/xxx/.ssh/config line 2: Unsupported option "rsaauthentication"
git@xxx.xxx.xxx.xxx's password:
Permission denied, please try again.
git@xxx.xxx.xxx.xxx's password:
34xxxPermission denied, please try again.
git@xxx.xxx.xxx.xxx's password:
git@xxx.xxx.xxx.xxx: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).
fatal: Could not read from remote repository.

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

??但奇怪的是,如果使用 HTTP 協議進行 clone、push 卻沒有任何問題。筆者在反復地卸載、重裝 GitLab,試了各種方法才發現,這個密碼其實是 GitLab 所在的 Linux 上的一個賬戶名為 git 的賬戶密碼。這個賬戶是怎么來的呢?實際上,在第一次使用命令 gitlab-ctl reconfigure 初始化 GitLab 配置時,GitLab 會自動為 Linux 創建五個賬戶,分別是:

  • git

  • gitlab-redis

  • gitlab-psql

  • gitlab-prometheus

  • gitlab-www

??因為這些賬戶在被創建時,GitLab 并沒有提示我們輸入密碼,所以我們并不知道密碼,或者它們本來就沒有密碼。不過,我們在知道賬戶名的時候就可以強制改密碼了。可以使用如下命令來更改賬戶 git 的密碼:

passwd git


??在設置完賬戶 git 的密碼后,筆者已經一切就已經結束了,結果后面還有一個大坑等著。在提示密碼后,輸入設置的賬戶 git 的密碼后,雖然沒有提示密碼錯誤,但 clone 時卻報了如下的錯誤:

git clone does not appear to be a git repository fatal: Could not read from remote repository.

??筆者反復檢查過,clone 時使用的 SSH 的 URL 是從 GitLab 項目中復制下來的,URL 沒有問題。在反復安裝不同的 Linux 與相應的 GitLab 后,這才發現原因。筆者前面安裝 GitLab 使用的 Linux 操作系統是 CentOS Stream 8,但截止至筆者編寫本博客時,GitLab 并未對 CentOS Stream 提供 GitLab 安裝包,于是筆者想當然地以 CentOS 8 安裝包來代替,所以在安裝后的 GitLab 的 SSH 環境不正確,以至于引發了各種問題。

??當筆者使用 CentOS 8 安裝 GitLab 后,在沒有主動設置賬戶 git 的密碼時,使用 SSH 協議進行 clone、push 時,不僅連輸入密碼這個過程都免了,也沒有產生任何報錯。

成功運行時的環境:

  • GitLab:gitlab-ee-14.3.6-ee.0.el8.x86_64

  • GitLab 上的 Linux:CentOS 8 x86_64

  • 遠程客戶端 Windows:Windows 10 教育版

原文鏈接:https://blog.csdn.net/wangpaiblog/article/details/122295579

欄目分類
最近更新