git版本庫服務器搭建

1、linux服務器端操作

1.1linu機器git-server上創建版本庫

[zydrgit@git-server ~]$ mkdir www.tomcatfox.com.git
[zydrgit@git-server ~]$ ls
www.tomcatfox.com.git
[zydrgit@git-server ~]$ git init --bare www.tomcatfox.com.git/
[zydrgit@git-server ~]$ cd www.tomcatfox.com.git/
Initialized empty Git repository in /home/zydrgit/www.tomcatfox.com.git/
[zydrgit@git-server www.tomcatfox.com.git]$ ls
branches  config  description  HEAD  hooks  info  objects  refs

1.2生成祕鑰文件存放目錄.ssh

生成存放祕鑰文件的.ssh目錄,來存放客戶端的公鑰文件,達到客戶端clone git版本庫代碼實現免密碼操作

[zydrgit@git-server ~]$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/zydrgit/.ssh/id_rsa): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /home/zydrgit/.ssh/id_rsa.
Your public key has been saved in /home/zydrgit/.ssh/id_rsa.pub.
The key fingerprint is:
59:7b:16:af:94:86:d1:2f:73:54:e9:6c:20:64:72:5b zydrgit@git-server
The key's randomart image is:
+--[ RSA 2048]----+
|         ..+ E  o|
|          +oo. o |
|          o.+ =  |
|         o + * + |
|        S o O =  |
|           = =   |
|            .    |
|                 |
|                 |
+-----------------+
[zydrgit@git-server ~]$ cd .ssh/
[zydrgit@git-server .ssh]$ ls
authorized_keys  id_rsa  id_rsa.pub

2、安裝git-bash軟件生成windows端的公私鑰文件

登錄git-bash操作生成windows端的公私鑰文件

j@DESKTOP-MKKM55A ~/.ssh
$ ssh-keygen.exe -t rsa
$ ls -al .ssh/*
-rw-r--r--    1 j        Administ     1679 Apr  8 16:55 .ssh/id_rsa
-rw-r--r--    1 j        Administ     1464 Apr  8 17:02 .ssh/id_rsa.ppk
-rw-r--r--    1 j        Administ      399 Apr  8 16:55 .ssh/id_rsa.pub
-rw-r--r--    1 j        Administ      395 Apr  8 16:57 .ssh/known_hosts

$ cat .ssh/id_rsa.pub
ssh-rsa AAAAB3NzaC1PDmPDVplq1o98hTE67pEDumgHE4f2BFS6K0ZPWDBNzCPf35LBng40ztPNNwAjXhUK6Gx0M8SMlTKstHgJKv+TILQdYf0G2/rcJSgMhE9u++dI9SRlK5p0gywiw+LEJhducqMrKGGALgrQoqGFQf36m2j j@DOP-MK55A

3、windows公鑰id_rsa.pub內容寫入版本庫機authorized_keys 文件中

給文件authorized_keys600權限
[zydrgit@git-server ~]$ chmod 600 .ssh/authorized_keys

4、登錄git-bash clone代碼

登錄windows端git-bash 實現免祕鑰clone代碼www.tomcatfox.com
git clone [email protected]:www.tomcatfox.com.git

git版本庫服務器搭建

git clone [email protected]:/home/zydrgit/www.tomcatfox.com.git

j@DESKTOP-MKKM55A ~/Desktop/11111111111
$ git clone [email protected]:/home/zydrgit/www.tomcatfox.com.git
Cloning into 'www.tomcatfox.com'...
warning: You appear to have cloned an empty repository.
Checking connectivity... done.

j@DESKTOP-MKKM55A ~/Desktop/11111111111
$ ls
www.tomcatfox.com

j@DESKTOP-MKKM55A ~/Desktop/11111111111

5、安裝putty生成.ppk文件通過TortoiseGit加載putty生成的.ppk文件實現免祕鑰clone和push代碼

當然也可以在windows電腦上安裝putty生成.ppk文件,通過TortoiseGit 軟件來加載putty生成的.ppk文件實現免祕鑰clone和push代碼

git版本庫服務器搭建

git版本庫服務器搭建

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章