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

學(xué)無(wú)先后,達(dá)者為師

網(wǎng)站首頁(yè) 編程語(yǔ)言 正文

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

作者:暗諾星刻 更新時(shí)間: 2022-05-11 編程語(yǔ)言

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

??筆者最近在新 Linux 中安裝 GitLab 后,發(fā)現(xiàn)一個(gè)詭異的事情。當(dāng)配置完管理員賬號(hào)、SSH 密鑰之后、開(kāi)啟防火墻端口號(hào)、在 GitLab 新建倉(cāng)庫(kù) test 等等之后,筆者嘗試在遠(yuǎn)程客戶(hù)端 Windows 上使用 git clone 來(lái) clone 這個(gè)在 GitLab 上的倉(cāng)庫(kù),使用的是 SSH 協(xié)議。但無(wú)論 clone 的 URL 是否正確,終端提示輸入密碼,且輸入任何密碼都不對(duì)。完整提示信息內(nèi)容如下:

筆者報(bào)錯(cuò)時(shí)的運(yùn)行環(huán)境:

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

  • GitLab 上的 Linux:CentOS Stream 8 x86_64

  • 遠(yuǎn)程客戶(hù)端 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 協(xié)議進(jìn)行 clone、push 卻沒(méi)有任何問(wèn)題。筆者在反復(fù)地卸載、重裝 GitLab,試了各種方法才發(fā)現(xiàn),這個(gè)密碼其實(shí)是 GitLab 所在的 Linux 上的一個(gè)賬戶(hù)名為 git 的賬戶(hù)密碼。這個(gè)賬戶(hù)是怎么來(lái)的呢?實(shí)際上,在第一次使用命令 gitlab-ctl reconfigure 初始化 GitLab 配置時(shí),GitLab 會(huì)自動(dòng)為 Linux 創(chuàng)建五個(gè)賬戶(hù),分別是:

  • git

  • gitlab-redis

  • gitlab-psql

  • gitlab-prometheus

  • gitlab-www

??因?yàn)檫@些賬戶(hù)在被創(chuàng)建時(shí),GitLab 并沒(méi)有提示我們輸入密碼,所以我們并不知道密碼,或者它們本來(lái)就沒(méi)有密碼。不過(guò),我們?cè)谥蕾~戶(hù)名的時(shí)候就可以強(qiáng)制改密碼了??梢允褂萌缦旅顏?lái)更改賬戶(hù) git 的密碼:

passwd git


??在設(shè)置完賬戶(hù) git 的密碼后,筆者已經(jīng)一切就已經(jīng)結(jié)束了,結(jié)果后面還有一個(gè)大坑等著。在提示密碼后,輸入設(shè)置的賬戶(hù) git 的密碼后,雖然沒(méi)有提示密碼錯(cuò)誤,但 clone 時(shí)卻報(bào)了如下的錯(cuò)誤:

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

??筆者反復(fù)檢查過(guò),clone 時(shí)使用的 SSH 的 URL 是從 GitLab 項(xiàng)目中復(fù)制下來(lái)的,URL 沒(méi)有問(wèn)題。在反復(fù)安裝不同的 Linux 與相應(yīng)的 GitLab 后,這才發(fā)現(xiàn)原因。筆者前面安裝 GitLab 使用的 Linux 操作系統(tǒng)是 CentOS Stream 8,但截止至筆者編寫(xiě)本博客時(shí),GitLab 并未對(duì) CentOS Stream 提供 GitLab 安裝包,于是筆者想當(dāng)然地以 CentOS 8 安裝包來(lái)代替,所以在安裝后的 GitLab 的 SSH 環(huán)境不正確,以至于引發(fā)了各種問(wèn)題。

??當(dāng)筆者使用 CentOS 8 安裝 GitLab 后,在沒(méi)有主動(dòng)設(shè)置賬戶(hù) git 的密碼時(shí),使用 SSH 協(xié)議進(jìn)行 clone、push 時(shí),不僅連輸入密碼這個(gè)過(guò)程都免了,也沒(méi)有產(chǎn)生任何報(bào)錯(cuò)。

成功運(yùn)行時(shí)的環(huán)境:

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

  • GitLab 上的 Linux:CentOS 8 x86_64

  • 遠(yuǎn)程客戶(hù)端 Windows:Windows 10 教育版

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

欄目分類(lèi)
最近更新