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

内容目录

准备工作

  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" => "[email protected]",
}
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.本站大部分内容均收集于网络!若内容若侵犯到您的权益,请发送邮件至:[email protected],工作室将第一时间处理!

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

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

LInux软件学习技术默认

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

2024-6-28 19:20:41

LinuxLInux软件学习默认

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

2024-7-22 20:19:47

0 条回复 A文章作者 M管理员
    暂无讨论,说说你的看法吧
个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索