gitlab兩種連接方式:ssh和http配置介紹


 

gitlab環境部署好后,創建project工程,在本地或遠程下載gitlab代碼,有兩種方式:ssh和http

1)ssh方式:這是一種相對安全的方式
要求將本地的公鑰上傳到gitlab中,如下圖:

window客戶機設置ssh方式連接gitlab,請見http://www.cnblogs.com/kevingrace/p/5651402.html(文章底部有介紹)

2)http連接方式

這種方式要求project在創建的時候只能選擇“Public”公開狀態,Private和Internal私有模式下不能使用http方式進行連接。(ssh方式在三種模式下都可以)。使用http方式直接連接gitlab顯然沒有ssh連接方式安全,但是也可以做些安全設置,比如在gitlab本機的iptables里做端口限制(如上是8081端口),添加白名單等。

 

 

===================================================
gitlab上創建的項目倉庫,要注意該倉庫下的members權限,如果某個gitlab用戶沒有設置在該倉庫members權限下,則使用該gitlab用戶進行git clone操作可以,但是進行git push則會失敗!報錯:remote: GitLab: You are not allowed to push code to protected branches on this project.

比如,使用gitlab的kevin用戶進行git上傳下載操作,kevin用戶默認沒有加到scanhost.git項目倉庫的member權限下。
1)git clone是可以的
[root@test ~]# git config --global user.name "王士博"
[root@test ~]# git config --global user.email "kevin@veredholdings.com"
[root@test ~]# git clone http://gitlab.kevin-inc.com/fanglianchao/scanhost.git
[root@test ~]# cd scanhost

2)git push則不允許,沒有權限
[root@test ~]# touch README.md
[root@test ~]# git add README.md
[root@test ~]# git commit -m "add README"
[root@test ~]# git push -u origin master
.......
remote: GitLab: You are not allowed to push code to protected branches on this project.
To http://gitlab.kevin-inc.com/fanglianchao/scanhost.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'http://gitlab.kevin-inc.com/fanglianchao/scanhost.git'

需要將kevin用戶加入到scanhost.git項目倉庫的member權限里,這樣就有權限進行git push了!


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM