美文网首页
GIT服务器安装手册

GIT服务器安装手册

作者: 陈旭员 | 来源:发表于2017-09-21 14:08 被阅读0次

    1.1.获取所需软件包

         git-2.4.2.tar.gz 下载地址去网上找找就好了,这里就不给出了

    1.2.安装步骤

    1.2.1.创建账户并配置环境变量

    创建git账户

        test@git>su - root

        root@git>useradd -d /home/git-mgit       #创建git用户

        root@>passwdgit#设置git用户的密码为:123456

    登入git

        root@git>su -git

    创建目录

         git@git>mkdir git#创建git服务器的根目录

        git@git>mkdir software#创建software目录用于存放安装用的软件

    1.2.2.安装软件包

    1.2.2.1 上传软件包

       首先使用git用户名登录

             进行uname -a查看系统的版本和位数。

             上传git-2.5.6.tar.gz到git账户的$HOME/software目录下。

       以下安装基于64位系统进行安装,如果系统为32位,只需更改软件包的名称

    1.2.2.2 安装Git

    [git@eb6381 ~]$ cd software/

    [git@eb6381 software]$ tar zxf git-2.5.6.tar.gz

    [git@eb6381 software]$ mv git-2.5.6/ /home/git

    [git@eb6381 software]$ cd

    [git@eb6381 ~]$ ls

    git  git-2.5.6  software

    |        + o ...o|

    |       .  o   .o.|

    |      o S  .  . o|

    |       o .E. o . |

    |      . = . . .  |

    |       * .       |

    |        o        |

    +-----------------+

    [git@eb6381 ~]$ cd .ssh/

    [git@eb6381 .ssh]$ ls

    id_rsa  id_rsa.pub

    服务器端Git打开RSA认证

    [git@eb6381 data]$ su root

    Password:

    [root@eb6381 data]# cd /etc/ssh

    [root@eb6381 ssh]# vi sshd_config

    #打开以下几行注释,保存并退出

    HostKey /etc/ssh/ssh_host_key

    RSAAuthentication yes

    PubkeyAuthentication yes

    AuthorizedKeysFile      .ssh/authorized_keys

    #重启sshd服务

    [root@eb6381 ssh]# service sshd restart

    Stopping sshd:                                             [  OK  ]

    Starting sshd:                                             [  OK  ]

    ���客户端clone仓库

    [git@eb6380 ~]$ git clone ssh://10.1.63.81:22/home/git/git/git-2.5.6/data/git/gittest.git

    Cloning into 'gittest'...

    git@10.1.63.81's password:

    warning: You appear to have cloned an empty repository.

    Checking connectivity... done.

    [git@eb6380 ~]$ ls

    git  gittest  git_test  httpd-2.4.27  software

    ssh-keygen–t rsa  //生成public key(id_rsa.pub)

    在git用户git家目录下新建一下文件:(有.ssh文件夹可以不用建,没有就建立一下)

    /home/git/.ssh/authorized_keys

    将id_rsa.pub内容添加到authorized_keys中;

    在另一台linux上测试git clone

    � 

    [git@eb6381 ~]$ cd git-2.5.6/

    [git@eb6381 git-2.5.6]$ ./configure

    [git@eb6381 git-2.5.6]$ make

    [git@eb6381 git-2.5.6]$ su root

    Password:

    [root@eb6381 git-2.5.6]# make install

    [root@eb6381 git-2.5.6]# exit

    [git@eb6381 git-2.5.6]$ git --version

    git version 2.5.6

    显示以上并是安装成功

    1.2.2.3.服务器端创建git仓库

    1.设置Git仓库 然后把Git仓库owner改成Git用户

    [git@eb6381 git-2.5.6]$ mkdir -p data/gittest.git

    [git@eb6381 git-2.5.6]$ git init --bare data/gittest.git

    Initialized empty Git repository in /home/git/git-2.5.6/data/gittest.git/

    [git@eb6381 git-2.5.6]$ cd data/

    [git@eb6381 data]$ chown -R git:git gittest.git/

    [git@eb6381 data]$ ll -a

    total 12

    drwxrwxr-x 3 git git 4096 Jul 13 16:31 .

    drwxrwxr-x 3 git git 4096 Jul 13 16:31 ..

    drwxrwxr-x 7 git git 4096 Jul 13 16:32 gittest.git

    1.2.2.4.客户端clone远程仓库

    生成公匙与私匙方法

    [git@eb6381 ~]$ git config --global user.name "hanhan"  #设置git  username

    [git@eb6381 ~]$ git config --global user.email"123456789@qq.com"#设置git的email

    [git@eb6381 ~]$ ssh-keygen -t rsa -C "123456789qq.com"   #生成git密钥

    Generating public/private rsa key pair.

    Enter file in which to save the key (/home/git/.ssh/id_rsa):

    Created directory '/home/git/.ssh'.

    Enter passphrase (empty for no passphrase):

    Enter same passphrase again:

    Your identification has been saved in /home/git/.ssh/id_rsa.

    Your public key has been saved in /home/git/.ssh/id_rsa.pub.

    The key fingerprint is:

    38:3f:4e:0e:d7:5d:5e:4d:78:c5:cd:ac:20:e6:81:bf 123456789qq.com

    The key's randomart image is:

    +--[ RSA 2048]----+

    |         .     +o|

    |        . + .  .*|

    [root@localhost ~]# git clone ssh://git@192.168.0.109/data/gittest.git

    Cloning into 'gittest'...

    warning: You appear to have cloned an empty repository.

    [root@localhost ~]# ls

    gittest

    相关文章

      网友评论

          本文标题:GIT服务器安装手册

          本文链接:https://www.haomeiwen.com/subject/vwezsxtx.html