標籤:style http 使用 strong 檔案 width
1.yum install lrzsz wget git
2.安裝gitosis:gitosis為Git使用者權限管理系統,通過管理服務端的/home/git/.ssh/authorized_key檔案來執行對使用者權限的管理,是一個python模組包
#yum install python python-setuptools
#git clone git://github.com/res0nat0r/gitosis.git
#cd gitosis/
#python setup.py install
顯示Finished processing dependencies for gitosis==0.2即表示成功
3.
訪問Gitolite需要通過SSH 金鑰來驗證。在用作GIT用戶端的電腦上如果還沒有密鑰(一個公開金鑰,一個私密金鑰),那麼可以使用ssh-keygen命令產生,然後將公開金鑰拷貝到GIT伺服器上。
$ ssh-keygen -t rsa “[email protected]”
這裡我們沒有指定產生的密鑰檔案名稱(可以通過-f filename指定),因此產生的檔案為id_rsa和id_rsa.pub,前者是私密金鑰,後者是公開金鑰。另外,在Linux下執行ssh-keygen可以同時指定該密鑰主人的email,這將出現在SSH公開金鑰內容中。
在Gitolite建立的GIT伺服器上,是通過修改gitolite-admin.git這個程式碼程式庫中的原始碼來建立新的程式碼程式庫、為GIT客戶添加登入用的公開金鑰的。所以要管理Gitolite,必須有一個git virtual user去git clone出gitolite-admin.git的代碼,這也就需要在伺服器本機建立一對SSH密鑰。
添加git使用者
adduser --system --shell /bin/sh --comment ‘git version control‘ --create-home --home-dir /home/git git
cd /home/git
rz 選擇你產生的ssh-key
4.su git
gitosis-init < ./id_rsa.pubchmod 755 /home/git/repositories/gitosis-admin.git/hooks/post-update
5.使用puttykeygenerator 轉換 pub為ppk
在Linux下產生的私密金鑰檔案putty是不認識的,putty只認識自己的ppk格式,要在這兩種格式之間轉換,需要PuTTYgen這個程式。
在安裝tortoisegit的時候會提示有選擇項:
如果選擇第一個,在安裝後配置git的時候就需要注意一些東西,如果選擇第二項則git的串連都是通過ssh完成,後續配置簡單一些。
選擇plink模式在git clone的時候需要載入ppk
putty key的產生方式:
啟動putty key generator
點擊load按鈕將剛才最先產生的ssh中的密鑰id_rsa檔案匯入,然後彈出對話方塊提示匯入成功,接著點擊save private key來儲存ppk檔案,最後在git clone的對話方塊中載入ppk檔案即可,串連的時候會提示輸入git使用者的密碼,輸入一下即可git clone gitosis的設定檔。
如果選擇ssh模式的tortoisegit,那麼就無需配置ppk,直接git clone。
這裡在對話方塊中的git url填寫的時候需要注意,是直接寫gitosis-admin.git,而不是加有/home/git的絕對路徑了。
6.如果是直接在linux伺服器上git clone,那麼要注意路徑問題:
git clone [email protected]:/home/git/repositories/gitosis-admin.git
否則寫會提示:
1 |
fatal: ‘gitosis-admin.git‘ does not appear to be a git repository |
2 |
fatal: The remote end hung up unexpectedly |
如果是windows下,不要加使用者名稱和絕對路徑否則會報錯
ERROR:gitosis.serve.main:Repository read access denied
git clone [email protected]:gitosis-admin.git
7.gitosis.conf
[gitosis]
[group gitosis-admin]
writable = gitosis-admin
members = [email protected] #顯示使用者[email protected]是初始化gitosis公開金鑰的擁有者,是唯一能管理gitosis-admin項目的人
[group jay_fans] #組名稱
members = [email protected] #密鑰使用者名稱 多個使用者名稱使用 空格隔開 [email protected] [email protected]
writable = git-test #項目名稱
三、常見問題
首先確定 /home/git/repositories/gitosis-admin.git/hooks/post-update 為可執行即屬性為 0755
1. git操作需要輸入密碼
-
原因
-
公密未找到
-
解決
-
上傳id_pub.rsa到keydir並改為‘gitosis帳號.pub‘形式,如miao.pub。副檔名.pub不可省略
2. ERROR:gitosis.serve.main:Repository read access denied
-
原因
-
gitosis.conf中的members與keydir中的使用者名稱不一致,如gitosis中的members = [email protected],但keydir中的公密名卻叫foo.pub
-
解決
-
使keydir的名稱與gitosis中members所指的名稱一致。
改為members = foo 或 公密名稱改為[email protected]
(3)出現’gitosis-admin’ does not appear to be a git repository,短路徑無效時替換為全路徑
在伺服器上使用短路徑會取現下面這個問題,原因是沒有找到對應匹配的密鑰所致,如果正確使用了ssh密鑰則不會出現這個問題,這裡就不去折騰了
[email protected]:/home/git/repositories# git clone [email protected]:gitosis-admin.gitCloning into gitosis-admin...[email protected]‘s password:fatal: ‘gitosis-admin‘ does not appear to be a git repositoryfatal: The remote end hung up unexpectedly
使用以下命令解決,只不過每次push和pull的時候都需要輸入一遍git使用者的密碼,略為繁瑣
git clone [email protected]:/home/git/repositories/gitosis-admin.git
(4)出現Unable to create temporary file: Permission denied
在Windows上使用TortoiseGit執行Push時出現以下錯誤
git.exe push --force --progress "origin" master:masterCounting objects: 189, done.Compressing objects: 100% (187/187)Writing objects: 7% (14/189)fatal: Unable to create temporary file: Permission deniedfatal: sha1 file ‘<stdout>‘ write error: Invalid argumenterror: failed to push some refs to ‘[email protected]:channelv.git‘git did not exit cleanly (exit code 1)
原來是伺服器上是用root賬戶建立的庫目錄,導致git賬戶無權寫入,方法就是修改檔案夾的所屬使用者和所屬使用者組
[email protected]:/home/git/repositories# chown -R git *[email protected]:/home/git/repositories# chgrp -R git *
(5)出現failed to push some refs to ‘[email protected]:channelv.git’
在Windows上使用TortoiseGit執行Push時出現以下錯誤
git.exe push --progress "origin" master:masterCounting objects: 189, done.Compressing objects: 100% (158/158)Writing objects: 100% (189/189), 1016.00 KiB | 997 KiB/sWriting objects: 100% (189/189), 1.12 MiB | 997 KiB/s, done.remote: error: ‘receive.denyCurrentBranch‘ configuration variable to ‘refuse‘.To [email protected]:channelv.git! [remote rejected] master -> master (branch is currently checked out)error: failed to push some refs to ‘[email protected]:channelv.git‘git did not exit cleanly (exit code 1)
在伺服器對應的庫目錄下執行以下命令增加配置即可
git config --bool core.bare true
6. 在git clone出gitolite-admin.git的代碼的時候,可能會出現”Agent admitted failure to sign using the key”這個問題,然後讓我們輸入hosting user的密碼。
$ git clone [email protected]:gitolite-admin.git
Cloning into ‘gitolite-admin‘...
Agent admitted failure to sign using the key.
[email protected]‘s password:
Permission denied, please try again.
[email protected]‘s password:
Permission denied, please try again.
[email protected]‘s password:
Permission denied (publickey,password).
fatal: The remote end hung up unexpectedly
$
這是SSH的問題。參考資料[3]中提供瞭解決方法:
https://help.github.com/articles/error-agent-admitted-failure-to-sign