網站首頁 編程語言 正文
解決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 的密碼:
??在設置完賬戶 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
相關推薦
- 2022-05-28 Entity?Framework?Core表名映射_實用技巧
- 2023-03-21 C++中如何將operator==定義為類的成員函數_C 語言
- 2023-02-02 Python實現自動生成請假條_python
- 2022-02-24 Kubernetes究竟是個容器應用程序還是集群操作系統,它這么復雜的原因出在哪?
- 2022-04-23 Linux基于客戶端用戶密鑰登錄服務端用戶
- 2022-12-08 React競態條件Race?Condition實例詳解_React
- 2022-10-14 SpringCloud組件之Gateway微服務網關
- 2023-01-14 Go?庫bytes.Buffer和strings.Builder使用及性能對比_Golang
- 最近更新
-
- window11 系統安裝 yarn
- 超詳細win安裝深度學習環境2025年最新版(
- Linux 中運行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎操作-- 運算符,流程控制 Flo
- 1. Int 和Integer 的區別,Jav
- spring @retryable不生效的一種
- Spring Security之認證信息的處理
- Spring Security之認證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權
- redisson分布式鎖中waittime的設
- maven:解決release錯誤:Artif
- restTemplate使用總結
- Spring Security之安全異常處理
- MybatisPlus優雅實現加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務發現-Nac
- Spring Security之基于HttpR
- Redis 底層數據結構-簡單動態字符串(SD
- arthas操作spring被代理目標對象命令
- Spring中的單例模式應用詳解
- 聊聊消息隊列,發送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠程分支