| 本帖最后由 木二 于 2022-10-11 23:56 编辑 
 
 一        KMS介绍 1.1        KMS概念 KMS,是 Key Management System 的缩写,也就是密钥管理系统。 对于 Windows 和 Office 而言,可用于激活 VOL (大众批量版),是 Windows Vista 之后的产品中的一种新型产品激活机制。 若用于测试环境,可在本地部署 KMS 服务器,本地的 Windows / Office 使用该 KMS 来临时激活。 KMS 可部署在 Windows 系统(通常不建议),也可部署在 Linux 服务器。 
 二        KMS部署 2.1        部署规划 本指南基于 Linux 部署,基于第三方开源 KMS 脚本快速实现部署。 注意:本脚本仅支持Debian、CentOS系统。 | 主机IP | 角色 | 备注 |  | 10.31.81.200 | KMS 服务器 | CentOS 8 |  | 10.31.81.201 | Windows 10 客户端 | 用于测试系统激活、office激活 | 
 2.2        基础准备 配置主机名,安装基于依赖,配置时钟服务器。复制代码[root@localhost ~]# hostnamectl set-hostname kmserver
[root@kmserver ~]# yum -y install gcc git make nss curl libcurl
复制代码[root@kmserver ~]# vim /etc/chrony.conf
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
server ntp1.aliyun.com iburst
server ntp2.aliyun.com iburst
server ntp3.aliyun.com iburst
# Record the rate at which the system clock gains/losses time.
driftfile /var/lib/chrony/drift
# Allow the system clock to be stepped in the first three updates
# if its offset is larger than 1 second.
makestep 1.0 3
# Enable kernel synchronization of the real-time clock (RTC).
rtcsync
# Enable hardware timestamping on all interfaces that support it.
#hwtimestamp *
# Increase the minimum number of selectable sources required to adjust
# the system clock.
#minsources 2
# Allow NTP client access from local network.
#allow 192.168.0.0/16
# Serve time even if not synchronized to a time source.
#local stratum 10
# Specify file containing keys for NTP authentication.
keyfile /etc/chrony.keys
# Get TAI-UTC offset and leap seconds from the system tz database.
leapsectz right/UTC
# Specify directory for log files.
logdir /var/log/chrony
# Select which information is logged.
#log measurements statistics tracking
[root@myvpn ~]# systemctl enable chronyd.service --now
 2.3        正式部署 采用开源脚本自动部署。 注意:本脚本默认在国外Git服务器,可能国内无法下载,已转存至本人国内服务器。 https://github.com/teddysun/across/raw/master/kms.sh 复制代码[root@kmserver ~]# wget http://down.linuxsb.com/tmp/teddysun/across/raw/master/kms.sh
[root@kmserver ~]# chmod +x kms.sh
[root@kmserver ~]# ./kms.sh
提示:如上所示,kms采用1688端口,需要客户端和KMS服务器之间放通1688端口策略。复制代码[root@kmserver ~]# netstat -tlunp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      1030/sshd           
tcp        0      0 0.0.0.0:1688            0.0.0.0:*               LISTEN      150117/vlmcsd       
tcp6       0      0 :::22                   :::*                    LISTEN      1030/sshd           
tcp6       0      0 :::1688                 :::*                    LISTEN      150117/vlmcsd       
udp        0      0 127.0.0.1:323           0.0.0.0:*                           693/chronyd         
udp6       0      0 ::1:323                 :::*                                693/chronyd
 2.4        其他管理 其他 kms 服务器管理命令参考如下: 复制代码[root@kmserver ~]# /etc/init.d/kms start                                    #启动kms服务
[root@kmserver ~]# /etc/init.d/kms stop                                     #停止kms服务
[root@kmserver ~]# /etc/init.d/kms restart                                  #重启kms服务
[root@kmserver ~]# /etc/init.d/kms status                                   #查看kms状态
[root@kmserver ~]# ./kms.sh uninstall                                       #卸载kms服务
 三        注册激活 3.1        Windows系统 KMS 仅能激活批量授权版本的系统,即 VL 版,VL 版本的镜像一般内置 GVLK key,用于 KMS 激活。 
 相关 Windows 系统镜像可从 MSDN我告诉你 下载,选择VL版(文件名中带有VL字符的版本),如 cn_windows_server_2012_r2_vl_x64_dvd_2979220.iso 。 
 若已安装的系统没有采用 VL 版本,也可手动重新导入 VL 版本的 key,然后再激活即可。 
 
 确认Windows系统版本,如本示例 Windows 10 专业版。 可通过如下命令在 cmd 中获取当前 Windows 系统版本。 复制代码C:\Windows\system32> wmic os get caption
进入Windows系统后,开始 ----> 运行 ----> cmd (管理员运行)。 复制代码C:\Windows\system32> slmgr /upk                                  #清除原安装密钥(若系统为未激活状态可省略)
C:\Windows\system32> slmgr /ipk W269N-WFGWX-YVC9B-4J6C9-T83GX    #安装对应版本的GVLK密钥
C:\Windows\system32> slmgr /skms 10.31.81.200                    #KMS服务器的域名或者内部IP
C:\Windows\system32> slmgr /ato                                  #执行KMS激活操作
 3.2        Office激活 KMS 仅能激活批量授权版本的系统,即 VL 版,VL 版本的镜像一般内置 GVLK key,用于 KMS 激活。 
 相关 Office 系统镜像可从 MSDN我告诉你 或者参考 简书 下载,选择VL版(文件名中带有VL字符的版本),如 SW_DVD5_Office_Professional_Plus_2016_64Bit_ChnSimp_MLF_X20-42426.ISO 。 
 若已安装的系统没有采用 VL 版本,也可手动重新导入 VL 版本的 key,然后再激活即可。ice 
 Office VL key 参考:
 进入Windows系统后,开始 ----> 运行 ----> cmd (管理员运行)。 复制代码C:\Windows\system32> cd C:\Program Files (x86)\Microsoft Office\Office16
C:\Program Files (x86)\Microsoft Office\Office16> cscript ospp.vbs /sethst:10.31.81.200
C:\Program Files (x86)\Microsoft Office\Office16> cscript ospp.vbs /act
提示:其他 Office 均参考此方式激活。 进入office确认激活成功。提示:若激活过程出现错误,可参考如下方式排查: 
 
 
 系统或 Office 是否修改过 Key 或未安装 GVLK Key;网络连接是否正常,和 KMS 服务器通信是否正常;
 |