git centos yum 安装 (服务器端 ,客户端)

21.git 服务器端安装 centos yum

21.1安装服务器端

yum install -y git
git --version 查看安装

21.2安装客户端

下载 Git for Windows,地址:https://git-for-windows.github.io/

git --version

21.3 创建 git 用户

[root@localhost home]# id git 
[root@localhost home]# useradd git
[root@localhost home]# passwd git

21.4服务器端创建 Git 仓库

设置 /home/data/git/gittest.git 为 Git 仓库 然后把 Git 仓库的 owner 修改为 git
[root@localhost home]# mkdir -p data/git/gittest.git
[root@localhost home]# git init --bare data/git/gittest.git
Initialized empty Git repository in /home/data/git/gittest.git/
[root@localhost home]# cd data/git/
[root@localhost git]# chown -R git:git gittest.git/

21.5客户端 clone 远程仓库

进入 Git Bash 命令行客户端,创建项目地址(设置在 I:\gitrespository)并进入

git clone [email protected]:/home/data/git/gittest.git
The authenticity of host '192.168.56.101 (192.168.56.101)' can't be established.
RSA key fingerprint is SHA256:Ve6WV/SCA059EqoUOzbFoZdfmMh3B259nigfmvdadqQ.
Are you sure you want to continue connecting (yes/no)? 
选择 yes: 
Warning: Permanently added '192.168.56.101' (RSA) to the list of known hosts.
ssh-keygen -t rsa -C "[email protected]"

 

 

21.6服务器端 Git 打开 RSA 认证

进入 /etc/ssh 目录,编辑 sshd_config,打开以下三个配置的注释:

RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys
保存并重启 sshd 服务:

[root@localhost ssh]# /etc/rc.d/init.d/sshd restart

 

 

[root@localhost git]#pwd
/home/git
[root@localhost git]# mkdir .ssh

[root@localhost git]# chown -R git:git .ssh
[root@localhost git]# ll -a
总用量 32
drwx------. 5 git  git  4096 8月  28 20:04 .
drwxr-xr-x. 8 root root 4096 8月  28 19:32 ..
-rw-r--r--. 1 git  git    18 10月 16 2014 .bash_logout
-rw-r--r--. 1 git  git   176 10月 16 2014 .bash_profile
-rw-r--r--. 1 git  git   124 10月 16 2014 .bashrc
drwxr-xr-x. 2 git  git  4096 11月 12 2010 .gnome2
drwxr-xr-x. 4 git  git  4096 5月   8 12:22 .mozilla
drwxr-xr-x. 2 git  git  4096 8月  28 20:08 .ssh

 

 

21.7将客户端公钥导入服务器端

/home/git/.ssh/authorized_keys 文件

回到 Git Bash 下,导入文件:

$ ssh [email protected] 'cat >> .ssh/authorized_keys' < ~/.ssh/id_rsa.pub

 需要输入服务器端 git 用户的密码

21.8回到服务器端,查看 .ssh 下是否存在 authorized_keys 文件

修改 .ssh 目录的权限为 700 修改 .ssh/authorized_keys 文件的权限为 600

[root@localhost git]# chmod 700 .ssh
[root@localhost git]# cd .ssh
[root@localhost .ssh]# chmod 600 authorized_keys 

 

 

21.9客户端再次 clone 远程仓库

git clone [email protected]:/home/data/git/gittest.git



 

21.10 测试上传 到git

 

 

捐助开发者

在兴趣的驱动下,写一个免费的东西,有欣喜,也还有汗水,希望你喜欢我的作品,同时也能支持一下。 当然,有钱捧个钱场(右上角的爱心标志,支持支付宝和PayPal捐助),没钱捧个人场,谢谢各位。



 
 谢谢您的赞助,我会做的更好!

猜你喜欢

转载自knight-black-bob.iteye.com/blog/2355248
今日推荐