標籤:os gitolite 配置 ios
前言:
之前學習了如何使用 git 後,一直想搭建一個本機搭建一個 git server 的,一開始不知道走了彎路用了 gitosis,折騰了我好幾天都沒配置好。昨晚查資料發現 gitosis 早就過時了,更新很慢取而代之的是 gitolite。後來在查看 gitosis 和 gitolite 的時候發現了這篇文章,其實如果對許可權要求不高的話,都不需要安裝 gitosis, gitolite,gitlab 之類的管理軟體,所以今天一大早起來就開始研究了,最終成功了。
參考文章1
參考文章2
一、建立一個 Standard 新使用者名稱為 git。
$ sudo chmod u+w /etc/sudoers$ sudo vi /etc/sudoers# 找到這一行 "root ALL=(ALL) ALL",在下面添加 "AccountName ALL=(ALL) ALL" (這裡是 git ALL=(ALL) ALL)並儲存。
二、client 端,設定為
三、驗證一下是否能串連上 git 使用者
$ ssh [email protected]# Are you sure you want to continue connecting (yes/no)? yes# Password: # Last login: Fri Jan 3 09:00:55 2014# exit
四、使用 ssh rsa 公開金鑰
1) 如果 client 端已經建立 ssh rsa 公開金鑰, 則執行 2),否則先建立:
$ cd ~$ ssh-keygen -t rsa # 預設存放路徑 ~/.ssh/id_rsa.pub
2) 把 ssh rsa 公開金鑰拷貝到 server 端 (id_rsa.pub 檔案在建立的時候,是可以改名的。這裡也可以先把 ~/.ssh/id_rsa.pub 拷貝到別的地方並重新命名 $ cp ~/.ssh/id_rsa.pub /tmp/yourName.pub)
$ ssh [email protected]Name.local mkdir .ssh # 登陸 server 並建立 .ssh 檔案夾$ scp ~/.ssh/id_rsa.pub [email protected].local:.ssh/authorized_keys# id_rsa.pub 100% 405 0.4KB/s 00:00
3) 修改 server 端的 sshd_config
$ ssh [email protected]$ cd /etc$ sudo chmod 666 sshd_config$ vi sshd_config#PermitRootLogin yes 改為 PermitRootLogin no# 下面幾項把前面的 #注釋 去掉#RSAAuthentication yes#PubkeyAuthentication yes#AuthorizedKeysFile .ssh/authorized_keys#PasswordAuthentication no#PermitEmptyPasswords no#UsePAM yes 改為 UsePAM no# exit
經過上面幾步已經配置好了,下面來測試一下了:
1) 在 server 端建立空的 repository
$ cd path/to$ mkdir newrepo.git$ cd newrepo.git$ git init --bare# --bare flag 只是用來儲存 pushes,不會當做本地 repository 來使用的。
2) 在 client 端,建立 local repository 並 push
$ cd path/to$ mkdir newrepo$ cd newrepo$ git init$ touch README$ git add .$ git commit -m "initial commit"$ git remote add origin git@yourComputerName:/path/to/newrepo.git # 如果直接之前在 server 端建立的 newrepo.git 是在 home 目錄,則這裡地址為:git@yourComputerName:newrepo.git$ git push origin master
iOS 在 mac os 上搭建 git server