gitlab-12.14.10-ee破解

基本情况

CentOS7.9
gitlab-12.14.10-ee

安装 ruby

  • 查看当前 ruby 的版本
yum list ruby --showduplicates | sort -r
  • 安装 ruby
yum install ruby -y

ruby -v # 查看安装的 ruby 版本

gem -v # 查看安装的 gem 版本
  • 安装 gitlab-license
# 切换 gem 源
[root@slam ~]# gem sources --list
*** CURRENT SOURCES ***

https://rubygems.org/
[root@slam ~]# gem sources --remove https://rubygems.org/ --add http://mirrors.aliyun.com/rubygems/

# 安装 gitlab-license
[root@slam ~]# gem install gitlab-license

安装 gitlab-license 的时候,会提示 ruby 版本太低,需要升级 ruby 版本,但是通过 yum 安装的,只能安装到 2.0.0 版本;可以通过 rvm 工具来进行 ruby 版本的升级切换。
安装 rvm:

  • 这步不是必须:安装一些依赖包:patch, autoconf, automake, bison, bzip2, gcc-c++, libffi-devel, libtool, patch, readline-devel, sqlite-devel, zlib-devel, glibc-headers, glibc-devel, openssl-devel
  • gpg2 --keyserver hkp://keyserver.ubuntu.com --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
  • 下载并安装 rvm:curl -sSL https://get.rvm.io | bash -s stable
  • 添加环境变量:echo "source /etc/profile.d/rvm.sh" >> /etc/profile
  • 生效环境变量:source /etc/profile
  • 查看 rvm 版本:rvm -v
  • 查看可安装的 ruby 版本:rvm list known
  • 安装需要的版本(使用第三方镜像地址):rrvm install ruby-2.7.2 --url https://cache.ruby-china.com/pub/ruby/2.7/ruby-2.7.2.tar.gz
  • 验证版本:ruby -v

license

写入以下文件内容:

mkdir ~/license

cat > ~/license/license.rb << 'EOF'
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(2021, 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

EOF

使用 ruby 命令生成文件 GitLabBV.gitlab-license,license_key,license_key.pub 三个文件。

cd ~/license/ && ruby license.rb
  • license_key.pub 这个是颁布的公钥
  • license_key 这个是私钥, 理论上拥有这个这个私钥就可以给更多gitlab instance颁发的公钥.
  • GitLabBV.gitlab-license 这个文件是许可文件.

使用许可证

  • 先备份 /opt/gitlab/embedded/service/gitlab-rails/.license_encryption_key.pub
  • cp ~/license/license_key.pub /opt/gitlab/embedded/service/gitlab-rails/.license_encryption_key.pub
  • 修改等级 将/opt/gitlab/embedded/service/gitlab-rails/ee/app/models/license.rb 文件中的 def plan 下的 STARTER_PLAN 修改为 ULTIMATE_PLAN
  • 重启gitlab: gitlab-ctl restart
  • gitlab管理页面 添加许可证 GitLabBV.gitlab-license