标签: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
登录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
给文件authorized_keys600权限
[zydrgit@git-server ~]$ chmod 600 .ssh/authorized_keys
登录windows端git-bash 实现免秘钥clone代码www.tomcatfox.com
git clone zydrgit@192.168.1.49:www.tomcatfox.com.git
git clone zydrgit@192.168.1.49:/home/zydrgit/www.tomcatfox.com.git
j@DESKTOP-MKKM55A ~/Desktop/11111111111
$ git clone zydrgit@192.168.1.49:/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
当然也可以在windows电脑上安装putty生成.ppk文件,通过TortoiseGit 软件来加载putty生成的.ppk文件实现免秘钥clone和push代码
标签:git版本库服务器搭建
原文地址:http://blog.51cto.com/wujianwei/2095786