CentOS 7 GITサーバの構築
4704 ワード
Gitはオープンソースの分散バージョン制御システムであり、プロジェクトのバージョン管理を効率的かつ高速に処理することができる.GitはLinus TorvaldsがLinuxカーネル開発の管理を支援するために開発したオープンソースのバージョン制御ソフトウェアである.
開発者はGITアカウントを必要とし、これによってプロジェクトの提出記録を表示し、プロジェクトの開発状況をより明確にすることができ、バージョン管理を容易にすることができる.
以下、CentOS 7について説明する.6オペレーティングシステムはGITサーバーを構築する.
一、GITサーバーのインストールプロセス
一つ一つ
インストールGIT:
アカウントの追加:
ユーザーパスワードの変更:
OSにログインしないようにユーザーを変更するには、次の手順に従います.
この場合gitアカウントはサブシステムにログインできません.git専用です.
ディレクトリの表示:
ディレクトリの作成:
ディレクトリへのアクセス:
倉庫の作成:
所属ユーザーがgitに変更されました.
これで、サーバプロセスが完了します.
二、秘密保護登録プロセス
証明書ログイン(サービス側):
編集可能/home/git/.ssh/authorized_keys、クライアントの公開鍵を入れます.(注:公開鍵1行です.)
公開鍵の作成(クライアント):
公開鍵をGITサーバにアップロードする:
サービス側はクライアント公開鍵をインポートします.
これで、秘密保護ログインプロセスが完了します.
三、倉庫が使用可能かどうかを検証する
クローニングウェアハウス:
倉庫へのデータの送信:
これで、倉庫プロセスの検証が完了しました.
この文書では、GITのインストール、機密保護の設定、倉庫の使用可能性の検証などについて簡単に説明します.より多くの応用内容については後述する.
開発者はGITアカウントを必要とし、これによってプロジェクトの提出記録を表示し、プロジェクトの開発状況をより明確にすることができ、バージョン管理を容易にすることができる.
以下、CentOS 7について説明する.6オペレーティングシステムはGITサーバーを構築する.
一、GITサーバーのインストールプロセス
一つ一つ
インストールGIT:
[root@git ~]# yum -y install git
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
......
Package git-1.8.3.1-20.el7.x86_64 already installed and latest version
アカウントの追加:
adduser git
ユーザーパスワードの変更:
passwd git
OSにログインしないようにユーザーを変更するには、次の手順に従います.
usermod -s git-shell git
この場合gitアカウントはサブシステムにログインできません.git専用です.
[root@git ~]# su git
su: failed to execute git-shell: Permission denied
ディレクトリの表示:
[root@git ~]# ls -al /home/git/
total 12
drwx------. 2 git git 62 Sep 2 06:24 .
drwxr-xr-x. 3 root root 17 Sep 2 06:24 ..
-rw-r--r--. 1 git git 18 Oct 31 2018 .bash_logout
-rw-r--r--. 1 git git 193 Oct 31 2018 .bash_profile
-rw-r--r--. 1 git git 231 Oct 31 2018 .bashrc
ディレクトリの作成:
[root@git ~]# mkdir /var/git/
[root@git ~]# mkdir /var/git/repositories
[root@git ~]# chown git:git /var/git/repositories
ディレクトリへのアクセス:
[root@git ~]# cd /var/git/repositories/
倉庫の作成:
[root@git repositories]# git init --bare test.git
Initialized empty Git repository in /var/git/repositories/test.git/
所属ユーザーがgitに変更されました.
[root@git repositories]# chown -R git:git test.git
これで、サーバプロセスが完了します.
二、秘密保護登録プロセス
証明書ログイン(サービス側):
mkdir /home/git/.ssh
chmod 700 /home/git/.ssh
chown -R git:git /home/git/.ssh
touch /home/git/.ssh/authorized_keys
chmod 600 /home/git/.ssh/authorized_keys
編集可能/home/git/.ssh/authorized_keys、クライアントの公開鍵を入れます.(注:公開鍵1行です.)
公開鍵の作成(クライアント):
[root@client ~]# ssh-keygen -t rsa -C "[email protected]"
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:d1dZ8KsaMzbS1LqahZqS266Xwe3I9vzu7xBKZozeGnA [email protected]
The key's randomart image is:
+---[RSA 2048]----+
| . E . |
| o . + |
| . o . + |
| + o o * . |
| . S.B.# + |
| *oO.& |
| o.+=B |
| +*..o |
| o=o.o=* |
+----[SHA256]-----+
公開鍵をGITサーバにアップロードする:
[root@client .ssh]# scp id_rsa.pub [email protected]:/home/git/.ssh
[email protected]'s password:
id_rsa.pub 100% 400 207.3KB/s 00:00
サービス側はクライアント公開鍵をインポートします.
[root@git .ssh]# cd /home/git/.ssh
[root@git .ssh]# cat id_rsa.pub >> authorized_keys
これで、秘密保護ログインプロセスが完了します.
三、倉庫が使用可能かどうかを検証する
クローニングウェアハウス:
[root@client git]# git clone [email protected]:/var/git/repositories/test.git
Cloning into 'test'...
warning: You appear to have cloned an empty repository.
倉庫へのデータの送信:
[root@client test]# vim README
[root@client test]# git add README
[root@client test]# git commit README -m "add README"
[master (root-commit) 09b3e98] add README
1 file changed, 1 insertion(+)
create mode 100644 README
[root@client test]# git push origin master
Counting objects: 3, done.
Writing objects: 100% (3/3), 232 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To [email protected]:/var/git/repositories/test.git
* [new branch] master -> master
これで、倉庫プロセスの検証が完了しました.
この文書では、GITのインストール、機密保護の設定、倉庫の使用可能性の検証などについて簡単に説明します.より多くの応用内容については後述する.