gitlab永久激活

gitlab永久激活
奔跑的中二患者添加 gitlab 安装包
ubuntu安装 官网教程
- 添加gitlab安装包
1
curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ee/script.deb.sh | sudo bash
可以查看有哪些版本的安装包1
apt-cache madison gitlab-ee
安装gitlab
1
2
3sudo GITLAB_ROOT_EMAIL="gitlab@pfhs.shop" \
GITLAB_ROOT_PASSWORD="gitlabtest" \
EXTERNAL_URL="http://127.0.0.1" apt install gitlab-ee这样安装下载得非常的慢
从官网下载离线的deb包手动上传的服务器进行安装 最新安装包
在本地开个代理下载快多了上传到服务器
重新修改安装脚本 把apt install gitlab-ee替换为dpkg -i package_name1
2
3sudo GITLAB_ROOT_EMAIL="gitlab@pfhs.shop" \
GITLAB_ROOT_PASSWORD="Test@qazW00.com" \
EXTERNAL_URL="http://127.0.0.1" dpkg -i ./gitlab-ee_17.3.0-ee.0_amd64.deb密码太简单报错了 更改一下
经过漫长的等待,看到以下输出
访问gitlab 使用默认账户root登录进去后默认是英文
更改默认系统全局默认语言为中文 在管理员设置-> 偏好设置 -> 本地化 >默认语言选择中文 保存刷新即可
激活gitlab-ee
安装完成后默认是没有有效订阅的,gitlab本身是开源的他的激活密钥也是开源的,
用大佬的脚本魔改下就可以了 参考项目
主要就是三个步骤 跟源码一样生成gitlab 公钥和私钥,通过公钥和私钥生成许可证 最后就是在gitlab添加生成的许可证
生成公钥和密钥
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#!/usr/bin/env ruby
# encoding: utf-8
require 'optparse'
require 'openssl'
public_key_file = nil
private_key_file = nil
OptionParser.new do |opts|
opts.banner = "Usage: generator.keys.rb [options]"
opts.on("--public-key PATH", "Specify public key file (required)") do |v|
public_key_file = File.expand_path(v)
end
opts.on("--private-key PATH", "Specify private key file (required)") do |v|
private_key_file = File.expand_path(v)
end
opts.on("-h", "--help", "Prints this help") do
puts opts
exit
end
end.parse!
if public_key_file.nil? || private_key_file.nil?
puts "[!] missing required options"
puts "[!] use -h for help"
exit 1
end
if File.exist?(private_key_file) || File.exist?(public_key_file)
puts "[!] key pair already exists"
puts "[!] remove them if you want to regenerate"
exit 1
end
puts "[*] generating rsa key pair..."
key = OpenSSL::PKey::RSA.new(2048)
File.write(private_key_file, key.to_pem)
File.write(public_key_file, key.public_key.to_pem)
puts "[*] done"将此创建一个文件 generator.keys.rb 将此脚本粘贴进去 用ruby执行即可生成公钥私钥
将这个对应的公钥私钥的 公钥替换gitlab的公钥
gitlab 公钥的路径为/opt/gitlab/embedded/service/gitlab-rails
如何是极狐版那么路径就是/opt/gitlab/embedded/service/gitlab-rails/jh
备份gitlab原有的公钥 让后把自己生成的移动到gitlab公钥那里1
2sudo mv .license_encryption_key.pub ./.license_encryption_key.pub.bak
sudo mv ~/public.key ./.license_encryption_key.pub根据公钥私钥生成license
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# encoding: utf-8
license_file_path = nil
license_json_path = nil
public_key_path = nil
private_key_path = nil
features_json_path = nil
require 'optparse'
OptionParser.new do |opts|
opts.banner = "Usage: generator.license.rb [options]"
opts.on("-o", "--output PATH", "Output to dir (required)") do |v|
license_file_path = File.expand_path(v)
end
opts.on("--public-key PATH", "Specify public key file (required)") do |v|
public_key_path = File.expand_path(v)
end
opts.on("--private-key PATH", "Specify private key file (required)") do |v|
private_key_path = File.expand_path(v)
end
opts.on("-f", "--features PATH", "Specify features json file (optional)") do |v|
features_json_path = File.expand_path(v)
end
opts.on("--plain-license PATH", "Export license in json if set, useful for debug. (optional)") do |v|
license_json_path = File.expand_path(v)
end
opts.on("-h", "--help", "Prints this help") do
puts opts
exit
end
end
.parse!
if license_file_path.nil? || public_key_path.nil? || private_key_path.nil?
puts "[!] missing required options"
puts "[!] use -h for help"
exit 1
end
# ==========
puts "[*] loading keys..."
require 'openssl'
PUBLIC_KEY = OpenSSL::PKey::RSA.new File.read(public_key_path)
PRIVATE_KEY = OpenSSL::PKey::RSA.new File.read(private_key_path)
puts "[*] loading licenses..."
require_relative '../lib/license.rb'
puts "[i] lib gitlab-license: #{Gitlab::License::VERSION}"
if !features_json_path.nil?
puts "[*] loading features from #{features_json_path}"
require 'json'
FEATURE_LIST = JSON.parse(File.read(features_json_path))
else
FEATURE_LIST = []
end
puts "[*] total features to inject: #{FEATURE_LIST.size}"
# ==========
puts "[*] building a license..."
Gitlab::License.encryption_key = PRIVATE_KEY
license = Gitlab::License.new
# don't use gitlab inc, search `gl_team_license` in lib for details
license.licensee = {
"Name" => "测试",
"Company" => "奔跑的中二患者",
"Email" => "gitlab@pfhs.shop"
}
# required of course
license.starts_at = Date.new(1976, 4, 1)
# required since gem gitlab-license v2.2.1
license.expires_at = Date.new(2500, 4, 1)
# prevent gitlab crash at
# notification_start_date = trial? ? expires_at - NOTIFICATION_DAYS_BEFORE_TRIAL_EXPIRY : block_changes_at
license.block_changes_at = Date.new(2500, 4, 1)
# required
license.restrictions = {
plan: 'ultimate',
# STARTER_PLAN = 'starter'
# PREMIUM_PLAN = 'premium'
# ULTIMATE_PLAN = 'ultimate'
active_user_count: 2147483647,
# required, just dont overflow
}
# restricted_attr will access restrictions
# add_ons will access restricted_attr(:add_ons, {})
# so here by we inject all features into restrictions
# see scan.rb for a list of features that we are going to inject
for feature in FEATURE_LIST
license.restrictions[feature] = 2147483647
end
puts "[*] validating license..."
if !license.valid?
puts "[E] license validation failed!"
puts "[E] #{license.errors}"
exit 1
end
puts "[*] license validated"
puts "[*] exporting license file..."
if !license_json_path.nil?
puts "[*] writing to #{license_json_path}"
File.write(license_json_path, JSON.pretty_generate(JSON.parse(license.to_json)))
end
puts "[*] writing to #{license_file_path}"
File.write(license_file_path, license.export)
puts "[*] done"需要将 1 提到的github大佬写的lib文件夹添加到脚本的当前目录,他说lib是直接从
gitlab源码里提取的 我找了一圈都没找到gitlab-ee的开源代码。1
2
3
4sudo ruby generator.license.rb \
--output ./gitlab.license \
--public-key /opt/gitlab/embedded/service/gitlab-rails/.license_encryption_key.pub \
--private-key ./private.key
将生成的gitlab.license的内容复制到gitlab的许可证里
在激活前需要重启下gitlab 使替换的公钥生效1
sudo gitlab-ctl restart
tips: 最后关闭掉服务禁ping 防止gitlab读取用户使用情况 官网指引






















