码迷,mamicode.com
首页 > 其他好文 > 详细

git-搭建企业git服务器

时间:2018-09-01 12:33:42      阅读:296      评论:0      收藏:0      [点我收藏+]

标签:lsh   attr   ica   git仓库   dir   auth   ide   known   systemctl   

1.安装 yum install git

2.增加用户 useradd git -d /home/git -g git

3.查看公钥鉴权文件是否存在  cat /home/git/.ssh/authorized_keys

4.不存在的话,新建

cd /home/git/
mkdir .ssh
chmod 755 .ssh
touch .ssh/authorized_keys
chmod 644 .ssh/authorized_keys

5.生成一个密钥对

ssh-keygen -t rsa -C "fallshum"

   是否输入密码,默认,一路Enter往下走就行

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:
1d:f1:b6:c9:42:2b:ab:1d:43:5a:72:fc:31:aa:38:9d fallshum
The key‘s randomart image is:
+--[ RSA 2048]----+
|          .      |
|           o     |
|          o o    |
|       . o = o   |
|      . S * +    |
|       * = +     |
|     ...= .      |
|    ..E+ o       |
|    ..o .        |
+-----------------+

5.1 把生成的公钥写入/home/git/.ssh/authorized_keys

cat /root/.ssh/id_rsa.pub >> /home/git/.ssh/authorized_keys

查看 cat /home/git/.ssh/authorized_keys

5.2 

把私钥放到客户端的.ssh目录下,先获取刚才生成的私钥

cat /root/.ssh/id_rsa

复制出来放到本地客户端

 

6.初始化Git仓库 修改所有者 
cd /home/git/

git init --bare fallshum.git

chown -R git:git fallshum.git/

5 客户端克隆仓库

客户端打开Git Bash,clone服务端仓库

git clone git@192.168.1.1:/home/git/fallshum.git

只要看到Checking connectivity... done就说明OK了

 ------------------------------------------------------------------------

遇到的问题 1:

The authenticity of host ‘IP‘ can‘t be established:

解决

https://yq.aliyun.com/articles/288093

解决方法

  1. 根据上面的理论,我们用下面的命令登录就不会出问题了。
ssh  -o StrictHostKeyChecking=no username@47.95.xxx.xxx
  1. 还有一种方法是彻底去掉提示,修改/etc/ssh/ssh_config文件(或$HOME/.ssh/config)中的配置,添加如下两行配置:
StrictHostKeyChecking no
UserKnownHostsFile /dev/null

修改好配置后,重新启动sshd服务即可,命令为:/etc/init.d/sshd restart (或 systemctl restart sshd )
当然,这是内网中非常信任的服务器之间的ssh连接,所以不考虑安全问题,就直接去掉了主机密钥(host key)的检查。

 

2.

git-搭建企业git服务器

标签:lsh   attr   ica   git仓库   dir   auth   ide   known   systemctl   

原文地址:https://www.cnblogs.com/tongbiao/p/9569126.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!