KMS,是 Key Management System 的缩写,也就是密钥管理系统。这里所说的 KMS,毋庸置疑就是用来激活 VOL 版本的 Windows 和 Office 的 KMS 啦。经常能在网上看到有人提供的 KMS 服务器地址,那么你有没有想过自己也来搞一个这样的服务呢?而这样的服务在 Github 上已经有开源代码实现了。

作者在这个开源代码的基础上,开发了适用于三大 Linux 发行版的一键安装 KMS 服务的脚本。

实际上,Github上的开源代码也支持Windows系统下的编译和部署。只是相对来说,这个一键部署脚本比较方便,且如果有服务器资源的话,可以长期运行,比较稳定。

当然还有一些部署好的在线KMS服务免费提供给大家使用,不过可能就是稳定性有限。

 

另外,也有KMS服务器的docker镜像,下载地址:luodaoyi/kms-server

感兴趣的也可以直接在Linux服务器(或者windows,不推荐)上通过docker 部署。

docker run -d docker.io/luodaoyi/kms-server

有关docker部署的资料可通过搜索查询到,不再赘述。通过docker部署KMS服务器更多细节可参考以下链接:

搭建私有KMS服务以激活用于实验的windows系统

 

后文主要介绍通过脚本直接部署和激活具体步骤。


 

脚本适用环境

系统支持:CentOS 6+,Debian 7+,Ubuntu 12+
虚拟技术:任意
内存要求:≥128M
日期 :2018 年 04 月 15 日

服务作用:在线激活windows和office

适用对象:VOL版本的windows和office

适用版本:截止到win10和office2016的所有版本

服务时间:服务器在线即提供服务

优点:在线激活 省时省力 无需安装软件 干净环保 命令简单

缺点:服务器不挂的话自动重新授权到服务器挂(服务器挂了还能继续180天)

 

关于本脚本

1、本脚本适用于三大 Linux 发行版,其他版本则不支持。
2、KMS 服务安装完成后会加入开机自启动。
3、默认记录日志,其日志位于 /var/log/vlmcsd.log。

使用方法

使用root用户登录,运行以下命令:

wget --no-check-certificate https://github.com/teddysun/across/raw/master/kms.sh && chmod +x kms.sh && ./kms.sh

安装完成后,输入以下命令查看端口号 1688 的监听情况:

netstat -nxtlp | grep 1688

返回值类似于如下这样就表示 OK 了:

tcp        0      0 0.0.0.0:1688                0.0.0.0:*                   LISTEN      3200/vlmcsd         
tcp        0      0 :::1688                     :::*                        LISTEN      3200/vlmcsd 

本脚本安装完成后,会将 KMS 服务加入开机自启动。

使用命令:
启动:/etc/init.d/kms start
停止:/etc/init.d/kms stop
重启:/etc/init.d/kms restart
状态:/etc/init.d/kms status

卸载方法:
使用 root 用户登录,运行以下命令: ./kms.sh uninstall 



如何使用 KMS 服务

KMS 服务,用于在线激活 VL 版本的 Windows 和 Office。

激活的前提是你的系统是批量授权版本,即 VL 版,一般企业版都是 VL 版。而 VL 版本的镜像一般内置 GVLK key,用于 KMS 激活。

可以到MSDN i tell you这个站点中下载相应镜像。建议下载时选择VL版(文件名中带有VL字符的版本)。

如果下载了非批量授权版本也没关系,只需要手动导入KMS Client Setup Key也可以使用KMS进行批量激活。不同版本的系统有不同的GVLK key,可以从微软官网找到:

另外,下面列表里面含有的产品的 VL 版本或者能使用 key 进入 KMS 通道的产品,都支持使用 KMS 激活。

Office 2016:https://technet.microsoft.com/zh-cn/library/dn385360(v=office.16).aspx
Office 2013:https://technet.microsoft.com/ZH-CN/library/dn385360.aspx
Office 2010:https://technet.microsoft.com/ZH-CN/library/ee624355(v=office.14).aspx
Windows:https://docs.microsoft.com/zh-cn/windows-server/get-started/kmsclientkeys

使用管理员权限运行 cmd 查看系统版本,命令如下: wmic os get caption 


使用管理员权限运行 cmd 安装从上面列表得到的 key,命令如下:

slmgr /ipk xxxxx-xxxxx-xxxxx-xxxxx-xxxxx

使用管理员权限运行 cmd 将 KMS 服务器地址设置为你自己的 IP 或 域名,命令如下:

slmgr /skms Your IP or Domain

注意:本脚本所做的工作就是此步骤。当你的 KMS 服务出于启动状态,那么此处就可以设置为你自己的 KMS 服务器地址。

使用管理员权限运行 cmd 手动激活系统,命令如下:

slmgr /ato

 

单独激活office说明

关于 Office 的激活,要求必须是 VOL 版本,否则无法激活。

找到你的 Office 安装目录,32 位默认一般为 C:\Program Files (x86)\Microsoft Office\Office16
64 位默认一般为 C:\Program Files\Microsoft Office\Office16
Office16 是 Office 2016,Office15 就是 Office 2013,Office14 就是 Office 2010。
打开以上所说的目录,应该有个 OSPP.VBS 文件。
使用管理员权限运行 cmd 进入 Office 目录,命令如下:

cd "C:\Program Files (x86)\Microsoft Office\Office16"

使用管理员权限运行 cmd 注册 KMS 服务器地址:

cscript ospp.vbs /sethst:Your IP or Domain

使用管理员权限运行 cmd 手动激活 Office,命令如下:

cscript ospp.vbs /act

注意: KMS 方式激活,其有效期只有 180 天。

每隔一段时间系统会自动向 KMS 服务器请求续期,请确保你自己的 KMS 服务正常运行。

常见错误的对策

如果遇到在执行过程报错,请按以下步骤检查:
1,你的 KMS 服务器是否挂了?
2,你的 KMS 服务是否正常开启?
3,你的系统或 Office 是否为批量 VL 版本?
4,你的系统或 Office 是否修改过 Key 或未安装 GVLK Key?
5,你是否以管理员权限运行 cmd?
6,你的网络连接是否正常?
7,你的本地 DNS 解析是否正常?
8,如果你排除了以上的对策,那请根据错误提示代码自行搜索原因。

 0x80070005错误一般是你没用管理员权限运行CMD

#############################################################################################################################################

【kms.sh】
#!/usr/bin/env bash # # Auto install KMS Server # System Required: CentOS 6+, Debian7+, Ubuntu12+ # Copyright (C) 2017-2018 Teddysun <i@teddysun.com> # URL: https://teddysun.com/530.html # # Thanks: https://github.com/Wind4/vlmcsd # red=\'\033[0;31m\' green=\'\033[0;32m\' yellow=\'\033[0;33m\' plain=\'\033[0m\' cur_dir=$(pwd) [[ $EUID -ne 0 ]] && echo -e "${red}Error:${plain} This script must be run as root!" && exit 1 if [ -f /etc/redhat-release ]; then release="centos" elif grep -Eqi "debian" /etc/issue; then release="debian" elif grep -Eqi "ubuntu" /etc/issue; then release="ubuntu" elif grep -Eqi "centos|red hat|redhat" /etc/issue; then release="centos" elif grep -Eqi "debian" /proc/version; then release="debian" elif grep -Eqi "ubuntu" /proc/version; then release="ubuntu" elif grep -Eqi "centos|red hat|redhat" /proc/version; then release="centos" else release="" fi boot_start(){ if [[ x"${release}" == x"debian" || x"${release}" == x"ubuntu" ]]; then update-rc.d -f "${1}" defaults elif [[ x"${release}" == x"centos" ]]; then chkconfig --add "${1}" chkconfig "${1}" on fi } boot_stop(){ if [[ x"${release}" == x"debian" || x"${release}" == x"ubuntu" ]]; then update-rc.d -f "${1}" remove elif [[ x"${release}" == x"centos" ]]; then chkconfig "${1}" off chkconfig --del "${1}" fi } # Get version getversion(){ if [[ -s /etc/redhat-release ]]; then grep -oE "[0-9.]+" /etc/redhat-release else grep -oE "[0-9.]+" /etc/issue fi } # CentOS version centosversion(){ if [[ x"${release}" == x"centos" ]]; then local code=$1 local version="$(getversion)" local main_ver=${version%%.*} if [ "$main_ver" == "$code" ]; then return 0 else return 1 fi else return 1 fi } get_opsy() { [ -f /etc/redhat-release ] && awk \'{print ($1,$3~/^[0-9]/?$3:$4)}\' /etc/redhat-release && return [ -f /etc/os-release ] && awk -F\'[= "]\' \'/PRETTY_NAME/{print $3,$4,$5}\' /etc/os-release && return [ -f /etc/lsb-release ] && awk -F\'[="]+\' \'/DESCRIPTION/{print $2}\' /etc/lsb-release && return } get_char() { SAVEDSTTY=$(stty -g) stty -echo stty cbreak dd if=/dev/tty bs=1 count=1 2> /dev/null stty -raw stty echo stty "$SAVEDSTTY" } set_firewall() { if centosversion 6; then /etc/init.d/iptables status > /dev/null 2>&1 if [ $? -eq 0 ]; then iptables -L -n | grep -i 1688 > /dev/null 2>&1 if [ $? -ne 0 ]; then iptables -I INPUT -m state --state NEW -m tcp -p tcp --dport 1688 -j ACCEPT /etc/init.d/iptables save /etc/init.d/iptables restart fi else echo -e "${yellow}Warning:${plain} iptables looks like shutdown or not installed, please enable port 1688 manually set if necessary." fi elif centosversion 7; then systemctl status firewalld > /dev/null 2>&1 if [ $? -eq 0 ]; then firewall-cmd --permanent --zone=public --add-port=1688/tcp firewall-cmd --reload else echo -e "${yellow}Warning:${plain} firewalld looks like shutdown or not installed, please enable port 1688 manually set if necessary." fi fi } install_main() { [ -f /usr/bin/vlmcsd ] && echo -e "${yellow}Warning:${plain} KMS Server is already installed. nothing to do..." && exit 1 clear opsy=$( get_opsy ) arch=$( uname -m ) lbit=$( getconf LONG_BIT ) kern=$( uname -r ) echo "---------- System Information ----------" echo " OS : $opsy" echo " Arch : $arch ($lbit Bit)" echo " Kernel : $kern" echo "----------------------------------------" echo " Auto install KMS Server" echo echo " URL: https://teddysun.com/530.html" echo "----------------------------------------" echo echo "Press any key to start...or Press Ctrl+C to cancel" char=$(get_char) if [[ x"${release}" == x"centos" ]]; then yum -y install gcc git make nss curl libcurl if ! wget --no-check-certificate -O /etc/init.d/kms https://raw.githubusercontent.com/teddysun/across/master/kms; then echo -e "[${red}Error:${plain}] Failed to download KMS Server script." exit 1 fi elif [[ x"${release}" == x"debian" || x"${release}" == x"ubuntu" ]]; then apt-get -y update apt-get install gcc git make libnss3 curl libcurl3-nss if ! wget --no-check-certificate -O /etc/init.d/kms https://raw.githubusercontent.com/teddysun/across/master/kms-debian; then echo -e "[${red}Error:${plain}] Failed to download KMS Server script." exit 1 fi else echo -e "${red}Error:${plain} OS is not be supported, please change to CentOS/Debian/Ubuntu and try again." exit 1 fi cd "${cur_dir}" || exit git clone https://github.com/Wind4/vlmcsd.git > /dev/null 2>&1 [ -d vlmcsd ] && cd vlmcsd || echo -e "[${red}Error:${plain}] Failed to git clone vlmcsd." make if [ $? -ne 0 ]; then echo -e "${red}Error:${plain} Install KMS Server failed, please check it and try again." exit 1 fi cp -p bin/vlmcsd /usr/bin/ chmod 755 /usr/bin/vlmcsd chmod 755 /etc/init.d/kms boot_start kms /etc/init.d/kms start if [ $? -ne 0 ]; then echo -e "${red}Error:${plain} KMS server start failed." fi if [[ x"${release}" == x"centos" ]]; then set_firewall fi cd "${cur_dir}" || exit rm -rf vlmcsd echo echo "Install KMS Server success" echo "Welcome to visit:https://teddysun.com/530.html" echo "Enjoy it!" echo } install_kms() { install_main 2>&1 | tee "${cur_dir}"/install_kms.log } # Uninstall KMS Server uninstall_kms() { printf "Are you sure uninstall KMS Server? (y/n) " printf "\n" read -p "(Default: n):" answer [ -z "${answer}" ] && answer="n" if [ "${answer}" == "y" ] || [ "${answer}" == "Y" ]; then /etc/init.d/kms status > /dev/null 2>&1 if [ $? -eq 0 ]; then /etc/init.d/kms stop fi boot_stop kms # delete kms server rm -f /usr/bin/vlmcsd rm -f /etc/init.d/kms rm -f /var/log/vlmcsd.log echo "KMS Server uninstall success" else echo echo "Uninstall cancelled, nothing to do..." echo fi } # Initialization step action=$1 [ -z "$1" ] && action=install case "$action" in install|uninstall) ${action}_kms ;; *) echo "Arguments error! [${action}]" echo "Usage: $(basename $0) [install|uninstall]" ;; esac

版权声明:本文为zmwgz原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://www.cnblogs.com/zmwgz/articles/10107172.html