当前位置: 首页 > news >正文

gitblit自建git仓库

在Ubuntu服务器

安装 java

sudo apt-get update
sudo apt-get install openjdk-8-jdk		# 或者其它你喜欢的版本

//sudo snap install gitblit

验证:

java -version

下载 gitblit

https://github.com/gitblit-org/gitblit/releases

解压/usr/local

tar -zxvf gitblit-1.9.3.tar.gz

修改配置文件

nano /usr/local/gitblit-1.9.3/data/defaults.properties
git.sshPort = 29418 //修改ssh端口号,建议不修改。
nano /usr/local/gitblit-1.9.3/data/gitblit.properties
server.httpPort = 8078 //修改http端口号(方便用浏览器登录访问)
server.httpsPort = 0
git.sshAuthenticationMethods = publickey password
git.sshAuthenticationMethods = publickey

这会禁用基于密码的SSH登录,仅支持使用预先配置的SSH公钥进行身份验证。
客户端在连接时也需要相应地禁用密码和交互式认证,只保留publickey:
ssh -o PreferredAuthentications=publickey user@gitblit
打开防火墙端口29418,8078.自定义tcp协议。

启动gitblit

/gitblit.sh &

设置随系统自动启动
修改服务脚本 ‘service-ubuntu.sh’

change theses values (default values)
GITBLIT_PATH=/usr/local/gitblit-1.9.3             # 路径要对应
GITBLIT_BASE_FOLDER=/usr/local/gitblit-1.9.3/data # 路径要对应
GITBLIT_USER="root"                               # 建议使用 root 用户

重启自启动:install the service

./install-service-ubuntu.sh
/etc/init.d/gitblit start

在window或mac

get clone ssh配置

  1. 在powershell里执行命令 ssh-keygen -t rsa “”,生成ssh密钥和公钥。
  2. 添加公钥到gitblit远程代码仓库中。

报错内容

Unable to negotiate with 192.168.77.12 port 29418: no matching host key type found. Their offer: ssh-rsa,ssh-dss
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.

上面的报错的意思是没有匹配到类型为 ssh-rsa 或 ssh-dss 的主机秘钥。但明明配置了ssh-rsa密钥和公钥啊。为什么git会识别不到呢?原来最新版本的git需要配置一个config文件才能提交代码到远程的gitblit仓库中。mark

解决方案

在~/.ssh的config中配置

Host xxx.xxx.xxx.xxx 
HostName xxx.xxx.xxx.xxx 
User gitblit
Port 29418 //防火墙放通,在服务器sshd_config不能配置Port 29418会冲突。
HostkeyAlgorithms +ssh-rsa //在新版git版本中务必配置。不然会出现需要rsa文件等奇怪提示。
PubkeyAcceptedKeyTypes +ssh-rsa //务必。此为大坑。mark。
IdentityFile ~/.ssh/id_rsa_subwindowsaws //chmod 600

注意:在windows的sourcetree程序:工具-选项,请选中ssh客户端为OpenSSH。
验证是否配置正确:

ssh -T gitblit@192.168.77.12
sudo systemctl start gitblit
sudo systemctl enable gitblit
sudo systemctl status gitblit
http://www.lryc.cn/news/258362.html

相关文章:

  • 二百一十一、Flume——Flume实时采集Linux中的Hive日志写入到HDFS中(亲测、附截图)
  • python 实现 AIGC 大模型中的概率论:生日问题的基本推导
  • YOLOv8算法改进【NO.87】引入上下文引导网络(CGNet)的Light-weight Context Guided改进C2_f
  • GPT-4V 在机器人领域的应用
  • Java基础语法之访问修饰限定符
  • 算法通关村第十八关 | 青铜 | 回溯
  • 蓝牙在物联网中的应用,相比WIFI和NFC的优势?
  • Altair推出 Altair RapidMiner 2023 平台,提供生成式 AI 功能
  • 包管理工具npm与yarn
  • 深度学习 Day11——T11优化器对比实验
  • (十六)Flask之蓝图
  • 面试问题--文件IO
  • SpringBoot中实现跨域的几种常用方式
  • MeterSphere实战(一)
  • ESP32-Web-Server编程-在网页中插入图片
  • <软考>软件设计师-4知识产权与标准化(总结)
  • 唯创知音WTVxxx语音芯片在免洗烘干机中的应用:提升用户体验与产品智能化
  • golang游戏服务器 - tgf系列课程06
  • 【Canvas】记录一次从0到1绘制风场空间分布图的过程
  • 如何用gpt改写文章 (1) 神码ai
  • IDEA版SSM入门到实战(Maven+MyBatis+Spring+SpringMVC) -Spring依赖注入数值问题
  • egen3 rowwise().maxCoeff()的使用
  • 关于Pytorch和Numpy中的稀疏矩阵sparse的知识点
  • 2024年AI云计算专题研究报告:智算带来的变化
  • 孩子还是有一颗网安梦——Bandit通关教程:Level 5 → Level 6
  • vue2-elementUI部分组件样式修改
  • fijkplayer flutter 直播流播放
  • Javascript的基本语法(规范)
  • vue chrome debugger 无效
  • JRT实现Cache的驱动