首页 » GIT » 正文

git安装文档

服务端:
#yum install -y git
#adduser mazhenguo
#mkdir /home/mazhenguo/.ssh/
客户端操作
#ssh-keygen -t rsa
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:
b1:44:b8:24:72:ad:30:cc:1d:18:2d:74:02:23:47:9f root@localhost.localdomain
The key’s randomart image is:
+–[ RSA 2048]—-+
|+**=oo ..        |
|.oO+=.+.         |
|   *E+ .o        |
|    . .. o       |
|        S        |
|                 |
|                 |
|                 |
|                 |
+—————–+
# cat ~/.ssh/id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA2BsDNuVEYgOqIiaujGvenKrUiciTa43P+vt12OURaRvxc6+foI8PRgv3UN06e88jut4k2EalHu4LE3m2d3Q2+MfP7+de5bFBSDEY/C7FPIamu4KNHgrZZ81/tJ2QeYAVx2ThY2mDOSyum6iYlp2vgxvcWcCflZGe8ux0fHO4wiprRasoCniNxYOL9IgYeJPywooxfWzoTbwKKkIR+hIBVB07s05E97UySxAhL0Tqa5pOSj4unygGum1t7Nri+SSfk89laugz3KQBewQCRBH0goULwSEWuiD5U8ihEi1yDIEmQH5tafIyC32q3UcDNeT+X8k1nCC8zZPWsEulQqJ5EQ== root@localhost.localdomain
服务端操作:
#vim /home/mazhenguo/.ssh/authorized_keys  //将客户端的id_rsa.pub文件内容增加到这个文件中
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA2BsDNuVEYgOqIiaujGvenKrUiciTa43P+vt12OURaRvxc6+foI8PRgv3UN06e88jut4k2EalHu4LE3m2d3Q2+MfP7+de5bFBSDEY/C7FPIamu4KNHgrZZ81/tJ2QeYAVx2ThY2mDOSyum6iYlp2vgxvcWcCflZGe8ux0fHO4wiprRasoCniNxYOL9IgYeJPywooxfWzoTbwKKkIR+hIBVB07s05E97UySxAhL0Tqa5pOSj4unygGum1t7Nri+SSfk89laugz3KQBewQCRBH0goULwSEWuiD5U8ihEi1yDIEmQH5tafIyC32q3UcDNeT+X8k1nCC8zZPWsEulQqJ5EQ== root@localhost.localdomain
:wq  //保存退出
//先选定一个目录作为Git仓库,这里是/home/git/project.git
#mkdir /home/git/
#cd /home/git/
#git init –bare project.git
#cd project.git/
#cd ..
#chown -R mazhenguo:mazhenguo project.git/
#cat /etc/passwd | grep mazhenguo
mazhenguo:x:501:501::/home/mazhenguo:/bin/bash
改为:
#vim /etc/passwd
mazhenguo:x:501:501::/home/mazhenguo:/usr/bin/git-shell
#git config branch.master.remote origin
#git config branch.master.merge refs/heads/master
这样,mazhenguo用户可以正常通过ssh使用git,但无法登录shell,因为我们为git用户指定的git-shell每次一登录就自动退出。
客户端的上操作
#git clone mazhenguo@10.23.2.4:/home/git/project.git  //其中mazhenguo用户名,10.23.2.4服务器,/home/git/project.git是仓库路径。
Initialized empty Git repository in /home/project/.git/
The authenticity of host ‘10.23.2.4 (10.23.2.4)’ can’t be established.
RSA key fingerprint is d4:14:18:ab:54:16:1f:29:db:df:7e:31:37:b4:b5:3e.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added ‘10.23.2.4’ (RSA) to the list of known hosts.
warning: You appear to have cloned an empty repository.

 

发表评论