日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > Ubuntu >内容正文

Ubuntu

ubuntu下面的git服务器搭建

發布時間:2023/12/20 Ubuntu 30 豆豆
生活随笔 收集整理的這篇文章主要介紹了 ubuntu下面的git服务器搭建 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

1、安裝相應的軟件和依賴


ubuntu:~$ sudo apt-get install git-core openssh-server openssh-client git-core是git版本控制核心軟件安裝openssh-server和openssh-client是由于git需要通過ssh協議來在服務器與客戶端之間傳輸文件然后中間有個確認操作,輸入Y后等待系統自動從鏡像服務器中下載軟件安裝,安裝完后會回到用戶當前目錄。如果安裝提示失敗,可能是因為系統軟件庫的索引文件太舊了,先更新一下就可以了,更新命令如下:ubuntu:~$ sudo apt-get update更新完軟件庫索引后繼續執行上面的安裝命令即可。
2、配置服務器

在服務器端

查看ssh有沒有啟動

root@weiqifa-Inspiron-3847:/home/git# ps -e|grep ssh1686 ? 00:00:00 sshd root@weiqifa-Inspiron-3847:/home/git#
創建git用戶,用來管理代碼的用戶

root@weiqifa-Inspiron-3847:/home/git# sudo useradd git useradd: user 'git' already exists root@weiqifa-Inspiron-3847:/home/git#
秘鑰文件

在gitServer上我們首先查看/home/git/.ssh目錄下是否存在authorized_kesys文件,

如果沒有,可以通過touch authorized_keys創建此文件。


在客戶機端

在客戶端用ssh-keygen -t rsa 生成秘鑰

然后用命令scp把秘鑰復制到服務器

scp id_rsa.pub weiqifa@192.168.0.88:/home/git/.ssh/
然后回到服務器

root@weiqifa-Inspiron-3847:/home/git/.ssh# ls authorized_keys id_rsa.pub root@weiqifa-Inspiron-3847:/home/git/.ssh# cat id_rsa.pub >> authorized_keys root@weiqifa-Inspiron-3847:/home/git/.ssh# cat authorized_keys ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDkIt2Hh532FoWoj0IUztIYF+jz4F1KvyOAmrhpxUMnnuj+YEOhyw6AGL/NAjmE5r8SzeJLTtAkVk9s143R9tYouPOgHPuwTTFvDy/skjD14yMne1aHzre2rM0jGiv5gtZDmi523FvQob7oTM5xOKKk3lsMBQNPdWrPPWqs8kS941sdWYymNQqFLBH4DpzDUAS+Itk5U6aNvVcQbldmGR+F3IxIKxH76HwpTmh+Os5fqraQLOMpWZzu8h0KMMMnNdideV0lHfq40Swb0ZO6ZGy/tdXBTc7oO8bn11oRVQ+Uf+USYMBzB6PCe6gODI3Fp0cBFzzQNque6MIAh6ELClUn Administrator@JU674J315CAOGPV root@weiqifa-Inspiron-3847:/home/git/.ssh#


3、建立倉庫并克隆
建立個文件夾用來管理倉庫

root@weiqifa-Inspiron-3847:/home/git# mkdir repo root@weiqifa-Inspiron-3847:/home/git# chown -R git:git repo/ root@weiqifa-Inspiron-3847:/home/git# chmod 700 repo/ root@weiqifa-Inspiron-3847:/home/git#
在服務器測試clone一下

root@weiqifa-Inspiron-3847:/home/git# cd repo/ root@weiqifa-Inspiron-3847:/home/git/repo# git init --bare sscom.git Initialized empty Git repository in /home/git/repo/sscom.git/ root@weiqifa-Inspiron-3847:/home/git/repo# cd ../ root@weiqifa-Inspiron-3847:/home/git# ls bin examples.desktop gitosis id_rsa.pub repo root@weiqifa-Inspiron-3847:/home/git# cd ../ root@weiqifa-Inspiron-3847:/home# git clone --bare git git/ gitrepository/ root@weiqifa-Inspiron-3847:/home# git clone --bare git/repo/sscom.git/ Cloning into bare repository 'sscom.git'... warning: You appear to have cloned an empty repository. done. root@weiqifa-Inspiron-3847:/home# ls git gitrepository lost+found sscom.git weiqifa root@weiqifa-Inspiron-3847:/home#


在客戶端clone一下

Administrator@JU674J315CAOGPV MINGW64 ~/.ssh $ git clone git@192.168.0.88:/home/git/repo/sscom.git Cloning into 'sscom'... git@192.168.0.88's password: warning: You appear to have cloned an empty repository. Checking connectivity... done.
在客戶端push 一下

Administrator@JU674J315CAOGPV MINGW64 ~/.ssh $ git clone git@192.168.0.88:/home/git/repo/sscom.git Cloning into 'sscom'... git@192.168.0.88's password: warning: You appear to have cloned an empty repository. Checking connectivity... done.Administrator@JU674J315CAOGPV MINGW64 ~/.ssh $ ls id_rsa id_rsa.pub known_hosts sample/ sscom/Administrator@JU674J315CAOGPV MINGW64 ~/.ssh $ cd sscom/Administrator@JU674J315CAOGPV MINGW64 ~/.ssh/sscom (master) $ ^CAdministrator@JU674J315CAOGPV MINGW64 ~/.ssh/sscom (master) $ lsAdministrator@JU674J315CAOGPV MINGW64 ~/.ssh/sscom (master) $ pwd /c/Users/Administrator/.ssh/sscomAdministrator@JU674J315CAOGPV MINGW64 ~/.ssh/sscom (master) $ git branchAdministrator@JU674J315CAOGPV MINGW64 ~/.ssh/sscom (master) $ echo "this beginnings of project1" > any.fileAdministrator@JU674J315CAOGPV MINGW64 ~/.ssh/sscom (master) $ git add . warning: LF will be replaced by CRLF in any.file. The file will have its original line endings in your working directory.Administrator@JU674J315CAOGPV MINGW64 ~/.ssh/sscom (master) $ git commit -m "init" [master (root-commit) e9565b2] init warning: LF will be replaced by CRLF in any.file. The file will have its original line endings in your working directory.1 file changed, 1 insertion(+)create mode 100644 any.fileAdministrator@JU674J315CAOGPV MINGW64 ~/.ssh/sscom (master) $ git push origin master git@192.168.0.88's password: Counting objects: 3, done. Writing objects: 100% (3/3), 229 bytes | 0 bytes/s, done. Total 3 (delta 0), reused 0 (delta 0) remote: error: insufficient permission for adding an object to repository database ./objects remote: fatal: failed to write object error: unpack failed: unpack-objects abnormal exit To git@192.168.0.88:/home/git/repo/sscom.git! [remote rejected] master -> master (unpacker error) error: failed to push some refs to 'git@192.168.0.88:/home/git/repo/sscom.git'
這個錯誤查看了一下這個鏈接

http://blog.csdn.net/yujunf/article/details/7595231

在服務器然后再修改一下

root@weiqifa-Inspiron-3847:/home/git/repo# ls sscom.git root@weiqifa-Inspiron-3847:/home/git/repo# chown -R git:git sscom.git/ root@weiqifa-Inspiron-3847:/home/git/repo#
回到客戶端再push一下

Administrator@JU674J315CAOGPV MINGW64 ~/.ssh/sscom (master) $ git push git@192.168.0.88's password: Counting objects: 3, done. Writing objects: 100% (3/3), 229 bytes | 0 bytes/s, done. Total 3 (delta 0), reused 0 (delta 0) To git@192.168.0.88:/home/git/repo/sscom.git* [new branch] master -> masterAdministrator@JU674J315CAOGPV MINGW64 ~/.ssh/sscom (master)

4、總結

1、原理問題查清楚,哪步在哪里執行,要搞清楚

2、認真仔細,ubuntu對用戶權限要求比較高,要特別注意一下

3、學會在網查資料


參考資料:

http://www.linuxdiyf.com/linux/12685.html

https://hacpai.com/article/1445337139234

http://www.linuxdiyf.com/linux/12159.html

http://www.linuxdiyf.com/linux/10730.html

http://www.gitguys.com/topics/creating-a-shared-repository-users-sharing-the-repository/

總結

以上是生活随笔為你收集整理的ubuntu下面的git服务器搭建的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。