centos8平台安裝gitosis服務

2022-06-28 21:27:12 字數 4367 閱讀 5204

1,確認openssh是否存在?如不存在,以下列命令進行安裝

[root@yjweb ~]#

yum install openssh openssh-server openssh-clients

2,安裝git

[root@yjweb ~]#

yum install git

判斷git是否安裝成功?

[root@yjweb ~]#

git --version

git version 2.18.2

3,安裝python工具

[root@yjweb ~]#

yum install -y python2 python2-setuptools

檢查python的setuptools是否安裝成功?

[root@yjweb gitosis]#

python2 -c "import setuptools"

如無任何輸出,表示安裝成功

如有報錯輸出,表示安裝失敗

說明:此處要使用python2

因為gitosis的初始化需要python2,

如果使用python3會報錯

對應的原始碼可以訪問這裡獲取: 

1,建立git使用者

[root@yjweb ~]#

groupadd git

[root@yjweb ~]#

useradd -g git git

[root@yjweb ~]#

grep git /etc/passwd

git:x:1003:1003::/home/git:/bin/bash

2,確保git使用者對git目錄有寫入許可權

[root@yjweb ~]#

chown git:git /home/git

[root@yjweb ~]#

ll /home/ | grep git

drwx------ 2 git git 62 mar 9 17:00 git

1,轉殖gitosis這個專案到本地的source資料夾

[root@yjweb source]#

git clone

cloning into 'gitosis'...remote: enumerating objects: 734, done.remote: total 734 (delta 0), reused 0 (delta 0), pack-reused 734receiving objects: 100% (734/734), 147.40 kib | 29.00 kib/s, done.resolving deltas: 100% (458/458), done.

2,安裝

[root@yjweb source]#

cd gitosis/

[root@yjweb gitosis]#

python2 setup.py install

說明:此處要使用python2

因為gitosis的初始化需要python2,

如果使用python3會報錯

說明:如果看到下面的提示表示安裝成功

finished processing dependencies for gitosis==0.2

[root@yjweb ~]#

mkdir -p /home/git/.ssh

[root@yjweb ~]#

chmod 700 /home/git/.ssh

[root@yjweb ~]#

touch /home/git/.ssh/authorized_keys

[root@yjweb ~]#

chown git.git -r /home/git

說明:authorized_keys檔案用來供gitosis儲存專案中的公鑰

說明:我們的開發機客戶端,是一台執行ubuntu 19.10的機器

1,建立ssh金鑰

說明:此處的客戶端是一台ubuntu機器

root@kubuntu:~#

ssh-keygen -t rsa

操作中一路回車即可,無需輸入密碼

2,檢查金鑰對是否生成

完成後可以從.ssh目錄下看到生成的金鑰對

root@kubuntu:~#

ls .ssh/

id_rsa id_rsa.pub known_hosts

其中 id_rsa.pub 是我們所要使用的公鑰

3,把生成的公鑰上傳到git伺服器

用scp或ftp工具,把id_rsa.pub複製到git伺服器上

放到/tmp目錄下

此處假設git伺服器的ip位址是:123.124.125.126,埠位址是12345

root@kubuntu:~#

scp -p 12345 .ssh/id_rsa.pub [email protected]:/tmp/

[email protected]'s password:

id_rsa.pub 100% 566 70.3kb/s 00:00

1,切換到git賬號,檢視客戶端上傳的公鑰是否存在?

[root@yjweb ~]#

su git

[git@yjweb root]$ ll /tmp/id_rsa.pub

-rw-r--r-- 1 sysop sysop 566 mar 9 18:46 /tmp/id_rsa.pub

2,初始化gitosis專案

[git@yjweb root]$ gitosis-init < /tmp/id_rsa.pub

initialized

empty git repository in /home/git/repositories/gitosis-admin.git/reinitialized existing git repository in /home/git/repositories/gitosis-admin.git/

3,初始化到底都做了哪些工作?

建立了乙個gitosis目錄和乙個庫目錄

[git@yjweb ~]$ ls

gitosis repositories

在.ssh目錄下的authorized_keys中寫入了id_rsa.pub的內容

[git@yjweb ~]$ cd .ssh

[git@yjweb .ssh]$ more authorized_keys

### autogenerated by gitosis, do not edit

command="gitosis-serve root@kubuntu",no-port-forwarding,no-x11-forwarding,no-agent-forwarding,no-pty ssh-rsa aaaab3nzac1yc2e

...

root@kubuntu:~# git clone ssh:

正轉殖到 'gitosis-admin'...

remote: enumerating objects: 5, done.

remote: counting objects: 100% (5/5), done.

remote: compressing objects: 100% (4/4), done.

remote: total 5 (delta 0), reused 0 (delta 0)

接收物件中: 100% (5/5), 完成.

root@kubuntu:~# ls

gitosis-admin node_modules package.json work

root@kubuntu:~/gitosis-admin# git remote -v

origin

ssh://

[email protected]:12345/gitosis-admin.git (fetch)

origin ssh://

[email protected]:12345/gitosis-admin.git (push)

[webop@yjweb ~]$ cat /etc/redhat-release

centos linux release 8.0.1905 (core)

參見這一篇:centos8上使用gitosis管理git專案

centos8平台使用lsof

lsof,list open files 列出當前系統開啟檔案的工具。在linux環境下,任何事物都以檔案的形式存在,所以lsof通過檔案不僅僅可以訪問常規資料,還可以訪問網路連線和硬體 對應的原始碼可以訪問這裡獲取 1,檢視lsof所屬的包 root blog whereis lsof lsof ...

centos8平台使用ulimit做系統資源限制

1,ulimit 用於shell啟動程序所占用的資源,可用於修改系統資源限制 2,使用ulimit a 可以檢視當前系統的所有限制值 使用ulimit n 可以同時開啟的檔案數 設定使用者可以同時開啟的最大檔案數 max open files 新裝的linux預設只有1024,當作為併發訪問量大的伺...

centos8平台給sudo配置日誌

我們可以記錄下來使用者賬號在哪個時間進行過sudo 這樣不需要再從secure日誌中查詢使用者的sudo記錄 對應的原始碼可以訪問這裡獲取 root blog touch var log sudo.log root blog sudoers.d visudo 增加三行配置 defaults logf...