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


原文鏈接:https://www.cnblogs.com/kevingrace/p/6114810.html

 

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端口),添加白名單等。

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