搭建一个企业级的Git托管平台Gitlab-EE 并附带破解使用企业版功能

AI智能摘要
本文详细介绍了搭建企业级Git托管平台GitLab-EE并激活企业版功能的完整流程。首先需要准备Ubuntu 24.x服务器、域名及FRP服务,依次安装系统依赖、Postfix和GitLab-EE软件包。配置环节需修改gitlab.rb文件设置访问域名,并通过Nginx反向代理实现端口转发。激活企业功能需安装Ruby环境,使用gitlab-license工具生成包含企业信息的许可证文件,修改系统密钥文件后上传许可证。最终通过重新配置并重启服务,即可获得支持10000用户量的GitLab企业版功能。
— AI 生成的文章内容摘要

准备工作

  1. 一个服务器有无公网ip都可以, 2c8g及以上, 并且安装了Ubuntu24.x
  2. 一个域名
  3. 一个frp服务器(如果你没有公网ip)

安装依赖

首先执行以下命令来安装必要的依赖库

$ sudo apt-get update
$ sudo apt-get install -y curl openssh-server ca-certificates tzdata perl

安装Postfix

$ sudo apt-get install -y postfix

添加Gitlab仓库

curl -s https://packages.gitlab.com/install/repositories/gitlab/gitlab-ee/script.deb.sh | sudo bash

安装最新版Gitlab-ee

$ apt-get install gitlab-ee

 

配置Gitlab 

打开 /etc/gitlab/gitlab.rb 修改external_url为你的域名例如https://repo.rtast.cn 如果你公开你的实例那么可以将external_url设置成内网可以访问的地址并加上端口号, 然后就配置结束了

如果你打算公开gitlab实例就设置external_url为域名并且加上https://, 使用vim的搜索模式搜索 nginx 然后找到以下内容

nginx['listen_port'] = 3000

修改一个没有被占用的端口, 然后打开你的nginx添加以下内容到 /etc/nginx/site-available/example.com

server {
    listen 3001 ssl;
    server_name repo.rtast.cn;
    ssl_certificate /etc/letsencrypt/live/rtast.cn/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/rtast.cn/privkey.pem;
    location / {
        client_max_body_size 512M;
        proxy_pass https://localhost:3000;
        proxy_set_header Connection $http_connection;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_read_timeout 300;
        proxy_connect_timeout 300;
        proxy_send_timeout 300;
    }
}

然后使用frp将3001暴露至公网

破解Gitlab-EE

首先你需要安装ruby解释器使用如下命令安装

$ sudo apt install ruby
$ ruby -v # 测试是否安装成功出现版本号就说明成功了
$ sudo gem install gitlab-license # 安装证书生成工具

然后创建一个license.rb文件内容是

require "openssl"
require "gitlab/license"

key_pair = OpenSSL::PKey::RSA.generate(2048)
File.open("license_key", "w") { |f| f.write(key_pair.to_pem) }

public_key = key_pair.public_key
File.open("license_key.pub", "w") { |f| f.write(public_key.to_pem) }

private_key = OpenSSL::PKey::RSA.new File.read("license_key")
Gitlab::License.encryption_key = private_key

license = Gitlab::License.new
license.licensee = {
  "Name" => "none",
  "Company" => "none",
  "Email" => "example@test.com",
}
license.starts_at = Date.new(2020, 1, 1) # 开始时间
license.expires_at = Date.new(2050, 1, 1) # 结束时间
license.notify_admins_at = Date.new(2049, 12, 1)
license.notify_users_at = Date.new(2049, 12, 1)
license.block_changes_at = Date.new(2050, 1, 1)
license.restrictions = {
  active_user_count: 10000,
}

puts "License:"
puts license

data = license.export
puts "Exported license:"
puts data
File.open("GitLabBV.gitlab-license", "w") { |f| f.write(data) }

public_key = OpenSSL::PKey::RSA.new File.read("license_key.pub")
Gitlab::License.encryption_key = public_key

data = File.read("GitLabBV.gitlab-license")
$license = Gitlab::License.import(data)

puts "Imported license:"
puts $license

unless $license
  raise "The license is invalid."
end

if $license.restricted?(:active_user_count)
  active_user_count = 10000
  if active_user_count > $license.restrictions[:active_user_count]
    raise "The active user count exceeds the allowed amount!"
  end
end

if $license.notify_admins?
  puts "The license is due to expire on #{$license.expires_at}."
end

if $license.notify_users?
  puts "The license is due to expire on #{$license.expires_at}."
end

module Gitlab
  class GitAccess
    def check(cmd, changes = nil)
      if $license.block_changes?
        return build_status_object(false, "License expired")
      end
    end
  end
end

puts "This instance of GitLab Enterprise Edition is licensed to:"
$license.licensee.each do |key, value|
  puts "#{key}: #{value}"
end

if $license.expired?
  puts "The license expired on #{$license.expires_at}"
elsif $license.will_expire?
  puts "The license will expire on #{$license.expires_at}"
else
  puts "The license will never expire."
end

license.licensee中的内容更改成你公司名称邮件地址

然后运行这个rb文件使用

$ ruby license.rb

运行完成之后会出现3个文件分别是私钥文件license_key 和公钥文件 license_key,pub 证书文件 GitLabBV.gitlab-license

你需要修改/opt/gitlab/embedded/service/gitlab-rails/.license_encryption_key.pub将这个文件的内容替换成 license_key.pub

然后修改/opt/gitlab/embedded/service/gitlab-rails/ee/app/models/license.rb搜索 def planrestricted_attr(:plan).presence || STARTER_PLAN 更改为 restricted_attr(:plan).presence || ULTIMATE_PLAN

然后重新配置gitlab并重启

$ gitlab-ctl reconfigure
$ gitlab-ctl restart

最后打开WebUI进入 Admin Area - General - Add License
GitLabBV.gitlab-license这个文件上传或者粘贴 点击Add license就完成了

温馨提示:

1.本站大部分内容均收集于网络!若内容若侵犯到您的权益,请发送邮件至:xiaoman1221@yhdzz.cn,工作室将第一时间处理!

2.资源所需价格并非资源售卖价格,是收集、整理、编辑详情以及本站运营的适当补贴,并且本站不提供任何免费技术支持。

3.所有资源仅限于参考和学习,版权归原作者所有。

LInux软件学习技术默认

在Ubuntu24环境下搭建一个可用的Git托管平台使用Gitea

2024-6-28 19:20:41

LinuxLInux软件学习默认

在配置Gitlab时出现的一些问题以及解决方法

2024-7-22 20:19:47

11 条回复 A文章作者 M管理员
  1. 笑声制造机

    老用户表示GitLab升级后配置文件老变,每次reconfigure都提心吊胆

  2. external_url设成内网地址的话,CI/CD还能正常回调吗?

  3. 哈哈哈终于不用求着公司买授权了,自己搭一个爽歪歪666

  4. 夜影之语

    ruby版本有要求不?我系统自带的是3.2会不会出问题

  5. NecroticSorcerer

    蹲个后续,要是能加个备份恢复流程就更稳了

  6. 啄木鸟医生

    感觉还行,不过2c8g跑GitLab真的够用?我上次4c16g都卡

  7. 改license那个地方是不是容易被官方检测到啊…有点慌

  8. IronWraith

    M1芯片的Mac能跑这个吗?还是必须x86服务器?

  9. 末日审判者

    前几天刚搭了个GitLab CE,现在看EE功能确实香,考虑照着弄一下

  10. 丛林探险者

    破解步骤有点多啊,怕搞崩了生产环境

  11. 圣骑士之光

    这教程看着挺全,但frp那块没公网IP真能行?🤔

个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索