在ubuntu上搭建git服务器

1、参考廖雪峰的博客搭建。
2、邮箱名最好和git的邮箱名保持一致。
在客户端生成ssh密钥。

[root@localhost storlead_project]# ssh-keygen -t rsa -C "zhangbo@storlead.com"
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:
ab:9b:80:d1:94:24:5f:67:2d:64:27:b3:14:4c:0f:97 zhangbo@storlead.com
The key's randomart image is:
+--[ RSA 2048]----+
|  . . .+%oo.     |
|   + o =oOE      |
|    +   ...      |
|   o             |
|  . .   S        |
|   o     .       |
|  . .   .        |
|     . o         |
|      +.         |
+-----------------+

在服务端添加ssh密钥。
将客户端/root/.ssh/id_rsa.pub里的内容全部复制粘贴到服务端的/home/git/.ssh/authorized_keys 里。

root@StorleadServ:/etc/ssh# cd /home/git/.ssh/
root@StorleadServ:/home/git/.ssh# vim authorized_keys 
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAtFnGwBNkgJK2dKFzXGuvSMb+7httfFUBYr072UO9sD4lp2xaDwuIrzpOy6FE5P+JUZxSnOXvFF/aja2ie17M8Fjp/0KUHb5aZ6sjIUur1Am1f5PVmmbx+XFl4xZtJBQLbRYxVmXzI8m+HZZkkNQhpYHxpDNJMGExo0POtgSEXlcN0Wl1gaYSxXB3+xlY4vU6LUWtGuUwJ5D+IrWzSQ7unXi4WWEscwFJIPplvskC1CUVsLI3NKc5eUEL71OcDoi0ar4HULldQj6KdPDOVb8DJiMONr3zb6AUiB/m4xRizyig4mlQWpI5sUTyESVvStOoOI5wvL8wWyfu9D3fMNk1fQ== xxxx@email.com

最好重启服务端的ssh服务。

3、在客户端克隆仓库的时候报错:

[root@localhost storlead_project]# git clone git@192.168.0.70:/opt/git/ast2400/sample.git
正克隆到 'sample'...
The authenticity of host '192.168.0.70 (192.168.0.70)' can't be established.
RSA key fingerprint is e2:d2:7f:87:5d:54:b4:0d:f1:74:be:d9:d4:3c:ba:08.
Are you sure you want to continue connecting (yes/no)? 
Host key verification failed.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

修该服务端的ssh配置文件/etc/ssh/ssh_config里的下面两行,然后重启ssh服务。

#   StrictHostKeyChecking no
#   UserKnownHostsFile /dev/null
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Jimbo_Zhang

有钱的捧个钱场

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值