ubuntu下面的git服务器搭建
1、安装相应的软件和依赖
ubuntu:~$ sudo apt-get install git-core openssh-server openssh-client
git-core是git版本控制核心软件安装openssh-server和openssh-client是由于git需要通过ssh协议来在服务器与客户端之间传输文件然后中间有个确认操作,输入Y后等待系统自动从镜像服务器中下载软件安装,安装完后会回到用户当前目录。如果安装提示失败,可能是因为系统软件库的索引文件太旧了,先更新一下就可以了,更新命令如下:ubuntu:~$ sudo apt-get update更新完软件库索引后继续执行上面的安装命令即可。
2、配置服务器
在服务器端
查看ssh有没有启动
root@weiqifa-Inspiron-3847:/home/git# ps -e|grep ssh1686 ? 00:00:00 sshd
root@weiqifa-Inspiron-3847:/home/git#
创建git用户,用来管理代码的用户
root@weiqifa-Inspiron-3847:/home/git# sudo useradd git
useradd: user 'git' already exists
root@weiqifa-Inspiron-3847:/home/git#
秘钥文件
在gitServer上我们首先查看/home/git/.ssh目录下是否存在authorized_kesys文件,
如果没有,可以通过touch authorized_keys创建此文件。
在客户机端
在客户端用ssh-keygen -t rsa 生成秘钥
然后用命令scp把秘钥复制到服务器
scp id_rsa.pub weiqifa@192.168.0.88:/home/git/.ssh/
然后回到服务器
root@weiqifa-Inspiron-3847:/home/git/.ssh# ls
authorized_keys id_rsa.pub
root@weiqifa-Inspiron-3847:/home/git/.ssh# cat id_rsa.pub >> authorized_keys
root@weiqifa-Inspiron-3847:/home/git/.ssh# cat authorized_keys
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDkIt2Hh532FoWoj0IUztIYF+jz4F1KvyOAmrhpxUMnnuj+YEOhyw6AGL/NAjmE5r8SzeJLTtAkVk9s143R9tYouPOgHPuwTTFvDy/skjD14yMne1aHzre2rM0jGiv5gtZDmi523FvQob7oTM5xOKKk3lsMBQNPdWrPPWqs8kS941sdWYymNQqFLBH4DpzDUAS+Itk5U6aNvVcQbldmGR+F3IxIKxH76HwpTmh+Os5fqraQLOMpWZzu8h0KMMMnNdideV0lHfq40Swb0ZO6ZGy/tdXBTc7oO8bn11oRVQ+Uf+USYMBzB6PCe6gODI3Fp0cBFzzQNque6MIAh6ELClUn Administrator@JU674J315CAOGPV
root@weiqifa-Inspiron-3847:/home/git/.ssh#
3、建立仓库并克隆
建立个文件夹用来管理仓库
root@weiqifa-Inspiron-3847:/home/git# mkdir repo
root@weiqifa-Inspiron-3847:/home/git# chown -R git:git repo/
root@weiqifa-Inspiron-3847:/home/git# chmod 700 repo/
root@weiqifa-Inspiron-3847:/home/git#
在服务器测试clone一下
root@weiqifa-Inspiron-3847:/home/git# cd repo/
root@weiqifa-Inspiron-3847:/home/git/repo# git init --bare sscom.git
Initialized empty Git repository in /home/git/repo/sscom.git/
root@weiqifa-Inspiron-3847:/home/git/repo# cd ../
root@weiqifa-Inspiron-3847:/home/git# ls
bin examples.desktop gitosis id_rsa.pub repo
root@weiqifa-Inspiron-3847:/home/git# cd ../
root@weiqifa-Inspiron-3847:/home# git clone --bare git
git/ gitrepository/
root@weiqifa-Inspiron-3847:/home# git clone --bare git/repo/sscom.git/
Cloning into bare repository 'sscom.git'...
warning: You appear to have cloned an empty repository.
done.
root@weiqifa-Inspiron-3847:/home# ls
git gitrepository lost+found sscom.git weiqifa
root@weiqifa-Inspiron-3847:/home#
在客户端clone一下
Administrator@JU674J315CAOGPV MINGW64 ~/.ssh
$ git clone git@192.168.0.88:/home/git/repo/sscom.git
Cloning into 'sscom'...
git@192.168.0.88's password:
warning: You appear to have cloned an empty repository.
Checking connectivity... done.
在客户端push 一下
Administrator@JU674J315CAOGPV MINGW64 ~/.ssh
$ git clone git@192.168.0.88:/home/git/repo/sscom.git
Cloning into 'sscom'...
git@192.168.0.88's password:
warning: You appear to have cloned an empty repository.
Checking connectivity... done.Administrator@JU674J315CAOGPV MINGW64 ~/.ssh
$ ls
id_rsa id_rsa.pub known_hosts sample/ sscom/Administrator@JU674J315CAOGPV MINGW64 ~/.ssh
$ cd sscom/Administrator@JU674J315CAOGPV MINGW64 ~/.ssh/sscom (master)
$ ^CAdministrator@JU674J315CAOGPV MINGW64 ~/.ssh/sscom (master)
$ lsAdministrator@JU674J315CAOGPV MINGW64 ~/.ssh/sscom (master)
$ pwd
/c/Users/Administrator/.ssh/sscomAdministrator@JU674J315CAOGPV MINGW64 ~/.ssh/sscom (master)
$ git branchAdministrator@JU674J315CAOGPV MINGW64 ~/.ssh/sscom (master)
$ echo "this beginnings of project1" > any.fileAdministrator@JU674J315CAOGPV MINGW64 ~/.ssh/sscom (master)
$ git add .
warning: LF will be replaced by CRLF in any.file.
The file will have its original line endings in your working directory.Administrator@JU674J315CAOGPV MINGW64 ~/.ssh/sscom (master)
$ git commit -m "init"
[master (root-commit) e9565b2] init
warning: LF will be replaced by CRLF in any.file.
The file will have its original line endings in your working directory.1 file changed, 1 insertion(+)create mode 100644 any.fileAdministrator@JU674J315CAOGPV MINGW64 ~/.ssh/sscom (master)
$ git push origin master
git@192.168.0.88's password:
Counting objects: 3, done.
Writing objects: 100% (3/3), 229 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
remote: error: insufficient permission for adding an object to repository database ./objects
remote: fatal: failed to write object
error: unpack failed: unpack-objects abnormal exit
To git@192.168.0.88:/home/git/repo/sscom.git! [remote rejected] master -> master (unpacker error)
error: failed to push some refs to 'git@192.168.0.88:/home/git/repo/sscom.git'
这个错误查看了一下这个链接
http://blog.csdn.net/yujunf/article/details/7595231
在服务器然后再修改一下
root@weiqifa-Inspiron-3847:/home/git/repo# ls
sscom.git
root@weiqifa-Inspiron-3847:/home/git/repo# chown -R git:git sscom.git/
root@weiqifa-Inspiron-3847:/home/git/repo#
回到客户端再push一下
Administrator@JU674J315CAOGPV MINGW64 ~/.ssh/sscom (master)
$ git push
git@192.168.0.88's password:
Counting objects: 3, done.
Writing objects: 100% (3/3), 229 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To git@192.168.0.88:/home/git/repo/sscom.git* [new branch] master -> masterAdministrator@JU674J315CAOGPV MINGW64 ~/.ssh/sscom (master)
4、总结
1、原理问题查清楚,哪步在哪里执行,要搞清楚
2、认真仔细,ubuntu对用户权限要求比较高,要特别注意一下
3、学会在网查资料
参考资料:
http://www.linuxdiyf.com/linux/12685.html
https://hacpai.com/article/1445337139234
http://www.linuxdiyf.com/linux/12159.html
http://www.linuxdiyf.com/linux/10730.html
http://www.gitguys.com/topics/creating-a-shared-repository-users-sharing-the-repository/
ubuntu下面的git服务器搭建相关推荐
- Ubuntu下求生之路2Linux服务器搭建(官方战役,三方药抗)
一个稍微新一点的,但也有段时间了:目前的个人博客 声明 本文章仅为萌新探索搭建服务器后写的初级总结,有问题请指出.更深层次的内容请自己去研究Sir大佬或者其他人的资料. 准备 首先你需要有服务器或者云 ...
- Gitea——私有git服务器搭建详细教程
本文将从源代码和docker安装两种方式带大家从0-1通过Gitea搭建一个私有git服务器 Gitea--私有git服务器搭建教程 什么是Gitea 一.源代码安装方式 1. 前置环境要求 2. 下 ...
- Gitea—私有git服务器搭建教程
Gitea--私有git服务器搭建详细教程 原文章大佬 原文链接:https://blog.csdn.net/qq_45173404/article/details/122277620 什么是Gite ...
- Ubuntu下架设FTP服务器(转)
Ubuntu下架设FTP服务器 Linux下提供了很多的ftp服务器,这里我选用了安全,快速,简单的vsftpd作为FTP服务器.本文是我在自己的Ubuntu 10.10 -32 位系统下搭建的.搭建 ...
- 基于Ubuntu18.04下深度学习服务器搭建
基于Ubuntu18.04下深度学习服务器搭建 目录: 基于Ubuntu18.04下深度学习服务器搭建 主要模块组成 Anaconda安装 CUDA安装 pytorch安装 CuDNN安装 其他常用指 ...
- Linux下NTP时间同步服务器搭建
NTP介绍 NTP 服务器是用于局域网服务器时间同步使用的,可以保证局域网所有的服 务器与时间服务器的时间保持一致,某些应用对时间实时性要求高的必须统一时 间. 互联网的时间服务器也有很多,例如 nt ...
- Git服务器搭建和配置
Git服务器搭建和配置 参考博客: 1.http://blog.csdn.net/michaelhan3/article/details/51637271 2.http://blog.csdn.net ...
- 搭建git服务器并管理系统,git服务器搭建与配置管理
git服务器搭建与配置管理 内容精选 换一换 弹性云服务器(Elastic Cloud Server)是一种可随时自动获取.计算能力可弹性伸缩的云服务器,可帮助您打造可靠.安全.灵活.高效的应用环境, ...
- ubuntu下安装ftp服务器
ubuntu下安装ftp服务器 Ftp服务器是使用以vsftp为例. 1. 安装 $sudo aptitude install vsftpd $ps aux | grep 'ftp' ...
最新文章
- swift_026(Swift 的类型转换)
- python爬虫如何从一个页面进入另一个页面-Python爬虫 (一):爬取一个简单的静态网页...
- 002_Java日志
- 我是SQL小菜鸟---SQL全局临时表防止用户重复登录
- shell linux教程,Shell入门基础知识
- python logging简单使用
- 企业如何考虑自己的网络防护设备
- matlab曲线拟合方法和函数拐点查找
- Windows安全基础-AD域
- Excel函数大全一《求和与统计函数》
- ITEXT7 实现 PDF文档的合并与拆分
- 嵌入式Linux开发环境搭建-4-嵌入式编程基础知识
- 文件加解密,AIDE入侵检测,扫描与抓包
- 03 学生免费注册Pycharm专业版
- Spark SQL: Relational Data Processing in Spark
- 【办公自动化】基于Python开发的PDF批量转换-合并应用程序
- 数字IC设计学习笔记_静态时序分析STA_伪路径False Paths
- Piwik网站流量访问统计系统
- Nginx网站服务配置
- 评测三款最流行的azw3阅读器(windows适用)
热门文章
- ThinkPHP 的URL重写时遇到No input file specified的解决方法
- svn添加用户.sh
- MVVM及MVVMLight相关资料
- java中原始数据文件的输入
- Android应用开发—TabLayout定制化Tab样式
- openfire服务器
- Python中“if __name__=='__main__':”理解与总结
- html里写js ajax吗,js、ajax、jquery的区别是什么?
- 手机处理器排行榜2019_手机处理器AI性能排行榜出炉,高通骁龙第一,华为排在第十名...
- canny算子的理论分析