当前位置:   article > 正文

gitblit自建git仓库_gitblit创建本地仓库

gitblit创建本地仓库

在Ubuntu服务器

安装 java

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

//sudo snap install gitblit

验证:

java -version
  • 1

下载 gitblit

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

解压/usr/local

tar -zxvf gitblit-1.9.3.tar.gz
  • 1

修改配置文件
nano /usr/local/gitblit-1.9.3/data/defaults.properties

git.sshPort = 29418       //修改ssh端口号,建议不修改。
  • 1

nano /usr/local/gitblit-1.9.3/data/gitblit.properties

server.httpPort = 8078   //修改http端口号(方便用浏览器登录访问)
server.httpsPort = 0
  • 1
  • 2

nano /usr/local/gitblit-1.9.3/data/defaults.properties

git.sshAuthenticationMethods = publickey password
git.sshAuthenticationMethods = publickey
  • 1
  • 2

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

启动gitblit

/gitblit.sh &
  • 1

设置随系统自动启动
修改服务脚本 ‘service-ubuntu.sh’,在change theses values (default values),
目录一定写正确,最好用cd /usr/local/gitblit-1.9.命令试下。不然会报错环境不正确。其实是没有找到gitblit的目录而已。

GITBLIT_PATH=/usr/local/gitblit-1.9.3             # 路径要对应
GITBLIT_BASE_FOLDER=/usr/local/gitblit-1.9.3/data # 路径要对应
GITBLIT_USER="root"                               # 建议使用 root 用户
  • 1
  • 2
  • 3

重启自启动

./install-service-ubuntu.sh
/etc/init.d/gitblit start
  • 1
  • 2
sudo systemctl start gitblit
sudo systemctl enable gitblit
sudo systemctl status gitblit
  • 1
  • 2
  • 3

在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.
  • 1
  • 2
  • 3
  • 4

上面的报错的意思是没有匹配到类型为 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
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7

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

ssh -T gitblit@192.168.77.12
  • 1
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Monodyee/article/detail/403108
推荐阅读
相关标签
  

闽ICP备14008679号