破解Gitlab ee 15 企业版
1. 前言
在破解之前, 我们要确保我们安装了合适版本的gitlab, 本文适用于gitlab 13, 14, 15等多个版本, 因为我是一路从gitlab13升级到15的, 对这些版本我都有亲自测试过, 此方法有效. 对于gitlab 16由于没有亲测过, 适用性未知, 希望试验过的朋友留言告知我, 在此提前表示感谢.
使用此教程的前提:
- 需要安装gitlab-ee 企业版
- 需要安装Ruby环境
2. 安装gitlab-ee企业版
关于如何安装配置gitlab-ee可以参考我的文章 鹏叔的技术博客 - gitlab安装升级及迁移
3. 环境说明
当前我的gitlab版本及环境如下:
操作系统版本: Centos 7.9
gitlab-ee版本为: 15.8.1-ee
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
$gitlab-rake gitlab:env:info
output:
System information
System:
Proxy: no
Current User: git
Using RVM: no
Ruby Version: 2.7.7p221
Gem Version: 3.1.6
Bundler Version:2.3.15
Rake Version: 13.0.6
Redis Version: 6.2.8
Sidekiq Version:6.5.7
Go Version: unknown
GitLab information
Version: 15.8.1-ee
Revision: c49deff6e37
DB Adapter: PostgreSQL
DB Version: 13.8
URL: http://gitlab.example.com
HTTP Clone URL: http://gitlab.example.com/some-group/some-project.git
SSH Clone URL: git@gitlab.example.com:some-group/some-project.git
Elasticsearch: no
Geo: no
Using LDAP: no
Using Omniauth: yes
Omniauth Providers:
4. 安装必要软件
4.1. 安装ruby
安装ruby:
1
2# 查看ruby版本
yum list ruby --showduplicates | sort -r在Centos7.9中,通过yum安装ruby的版本是2.0.0,但是本破解过程需要2.5或以上版本的ruby环境
所以需要先添加ruby25 yum源再安装ruby1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16yum install centos-release-scl-rh # 会在/etc/yum.repos.d/目录下多出一个CentOS-SCLo-scl-rh.repo源
yum install -y rh-ruby25 # 直接yum安装即可
scl enable rh-ruby25 bash # 必要的一步
# 如果遇到ruby找不到的情况, 修改以下两个环境变量
export PATH=$PATH:/opt/rh/rh-ruby25/root/bin
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/rh/rh-ruby25/root/lib64
ruby -v //查看安装版本
# ruby 2.5.9p229 (2021-04-05 revision 67939) [x86_64-linux]
gem -v //查看gem安装版本
2.7.6.3
4.2. 安装gitlab-license
1 | gem install gitlab-license |
5. 破解方法
创建一个rb文件
1
2cd /var/opt/gitlab/backups
cat > license.rb将如下内容拷贝到license.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
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生成 GitLabBV.gitlab-license license_key license_key.pub 这三个文件。
使用以下命令生成 GitLabBV.gitlab-license license_key license_key.pub 这三个文件
1
2cd /var/opt/gitlab/backups
ruby license.rblicense_key.pub 这个是颁布的公钥
license_key 这个是私钥, 理论上拥有这个这个私钥就可以给更多gitlab instance颁发的公钥.
GitLabBV.gitlab-license 这个文件是许可文件.使用许可证
首先备份 /opt/gitlab/embedded/service/gitlab-rails/.license_encryption_key.pub
1
cp /opt/gitlab/embedded/service/gitlab-rails/.license_encryption_key.pub /opt/gitlab/embedded/service/gitlab-rails/.license_encryption_key.pub.backup
用 license_key.pub 文件替换 /opt/gitlab/embedded/service/gitlab-rails/.license_encryption_key.pub文件
1
cp /var/opt/gitlab/backups/license_key.pub /opt/gitlab/embedded/service/gitlab-rails/.license_encryption_key.pub
修改等级
将登记从STARTER_PLAN修改为ULTIMATE_PLAN
1
2
3
4
5
6
7
8
9
10
11--- /opt/gitlab/embedded/service/gitlab-rails/ee/app/models/license.rb
+++ /opt/gitlab/embedded/service/gitlab-rails/ee/app/models/license.rb
end
def plan
- restricted_attr(:plan).presence || STARTER_PLAN
+ restricted_attr(:plan).presence || ULTIMATE_PLAN
end
def edition重启gitlab
1
gitlab-ctl restart
刚刚
ruby license.rb
执行后生成的三个文件其中 GitLabBV.gitlab-license 即是许可证,浏览器打开gitlab管理页面 http://${your_gitlab_server_address}/admin/application_settings/general 例如:http://localhost:8080/admin/application_settings/general展开 add license
勾选Enter license key, 填入license,
勾选terms of service 点击add license按钮,
当看到这段话, 表示成功。
The license was successfully uploaded and is now active. You can see the details below.
6. 关联阅读
7. 参考文档
破解Gitlab ee 15 企业版