林中两路分,一路人迹稀。我独选此路,境遇乃相异。

0%

在debian中搭建kms服务器


自己搭建一套kms服务器,用于激活vl版本的windows 和 office。

1. 下载程序

下载搭建服务的应用程序,地址:https://github.com/Wind4/vlmcsd/releases
下载后,解压缩,在binaries目录下有各种平台的相关程序;找到文件夹 binaries\Linux\intel\glibc\vlmcsd-x64-glibc,具体要根据部署的操作系统的版本,64位则选择 vlmcsd-x64-glibc,32位则选择 vlmcsd-x86-glibc;如果还有其他系统的,则选择相应的文件夹。

2. 部署程序

将程序部署到 /opt/vlmcsd中,没有相应目录,则新建,将 vlmcsd-x64-glibc复制到该目录下。

1
2
$ sudo mkdir /opt/vlmcsd
$ sudo cp /share/vlmcsd-x64-glibc /opt/vlmcsd/vlmcsd-x64-glibc

修改 vlmcsd-x64-glibc 执行权限:

1
2
$ cd /opt/vlmcsd
$ sudo chmod u+x vlmcsd-x64-glibc

3. 启动程序

1
$ sudo ./vlmcsd-x64-glibc

查看进程,是否已经启动:

1
$ ps aux|grep vlmcsd

如果显示以下内容,则表示启动成功

1
2
root       549  0.0  0.0   8508   128 ?        Ss   16:05   0:00 ./vlmcsd-x64-glibc
root 563 0.0 0.0 18084 984 pts/0 S+ 16:21 0:00 grep vlmcsd-x64-glibc

如果其他程序占用了端口1688,则会报错

1
2
Warning: 0.0.0.0:1688: Address already in use  
Fatal: Could not listen on any socket

关闭相应的程序即可。

4.添加开机自启

添加开机自启,最简单的方法就是使用rc.local,但是debian9默认没有rc.local文件,需要手动添加,但rc.local服务还是自带的,我们可以查看一下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
cat /lib/systemd/system/rc-local.service
# This file is part of systemd.
#
# systemd is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.

# This unit gets pulled automatically into multi-user.target by
# systemd-rc-local-generator if /etc/rc.local is executable.
[Unit]
Description=/etc/rc.local Compatibility
ConditionFileIsExecutable=/etc/rc.local
After=network.target

[Service]
Type=forking
ExecStart=/etc/rc.local start
TimeoutSec=0
RemainAfterExit=yes
GuessMainPID=no

4.1 添加rc-local.service

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
cat > /etc/systemd/system/rc-local.service <<EOF
[Unit]
Description=/etc/rc.local
ConditionPathExists=/etc/rc.local

[Service]
Type=forking
ExecStart=/etc/rc.local start
TimeoutSec=0
StandardOutput=tty
RemainAfterExit=yes
SysVStartPriority=99

[Install]
WantedBy=multi-user.target
EOF

4.2 新建rc.local 文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
cat > /etc/rc.local <<EOF
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

exit 0
EOF

4.3 添加权限,设置开机启动

1
2
3
chmod +x /etc/rc.local
systemctl enable rc.local
systemctl start rc-local.service

查看服务状态

1
systemctl status rc-local.service

如果显示 以下信息,包含 Active: active,则表示成功:

1
2
3
4
● rc.local.service - /etc/rc.local
Loaded: loaded (/etc/systemd/system/rc-local.service; enabled; vendor preset: enabled)
Active: active (exited) since Tue 2019-02-26 21:24:36 CST; 15s ago
Process: 542 ExecStart=/etc/rc.local start (code=exited, status=0/SUCCESS)

好了,将开机执行的脚本放在/etc/rc.localexit 0 之前,系统重启,就可以开机自动执行了。

1
2
# 在/etc/rc.local中添加脚本
/opt/vlmcsd/vlmcsd-x64-glibc -l /var/log/vlmcsd-x64-glibc.log > /dev/null 2>&1

5 windows客户端测试

在下载的程序包中找到\binaries\Windows\intel\vlmcs-Windows-x64.exe,同样,32位系统执行vlmcs-Windows-x86.exe
将当前目录 cd 切换到\binaries\Windows\intel,然后执行:

1
vlmcs-Windows-x64.exe -v -l 3 192.168.56.2

参数说明可以通过 vlmcs-Windows-x64.exe -x命令来查看
其中
-v 表示 输出详细信息
-l 3 表示发送Windows Server 2008 Datacenter的激活请求

返回结果如下,则表示服务器搭建成功

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
Request Parameters
==================

Protocol version : 6.0
Client is a virtual machine : No
Licensing status : 2 (OOB grace)
Remaining time (0 = forever) : 43200 minutes
Application ID : 55c92734-d682-4d71-983e-d6ec3f16059f (Windows)
SKU ID (aka Activation ID) : 34e1ae55-27f8-4950-8877-7a03be5fb181 (Windows Server 2019 Datacenter)
KMS ID (aka KMS counted ID) : 8449b1fb-f0ea-497a-99ab-66ca96e9a0f5 (Windows Server 2019)
Client machine ID : 548be75c-e4bd-4479-b164-1675d689874a
Previous client machine ID : 00000000-0000-0000-0000-000000000000
Client request timestamp (UTC) : 2019-02-26 14:05:52
Workstation name : ceo-laptop.borland.me
N count policy (minimum clients): 5

Connecting to 192.168.56.2:1688 ... successful

Performing RPC bind ...
... NDR64 ... BTFN ... NDR32 ... successful
Sending activation request (KMS V6) 1 of 1

Response from KMS server
========================

Size of KMS Response : 260 (0x104)
Protocol version : 6.0
KMS host extended PID : 03612-00206-556-735360-03-1050-14393.0000-2892018
KMS host Hardware ID : 3A1C049600B60076
Client machine ID : 548be75c-e4bd-4479-b164-1675d689874a
Client request timestamp (UTC) : 2019-02-26 14:05:52
KMS host current active clients : 50
Renewal interval policy : 10080
Activation interval policy : 120
-------------本文结束 感谢您的阅读-------------
觉得好,点这里 ^_^
  • 本文标题:在debian中搭建kms服务器
  • 本文作者: PenseeStroller
  • 本文链接: http://invictuscj.win/articles/os/win-kms/
  • 许可协议: 本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!