本文参考自:

https://github.com/dakkidaze/one-key-kms
https://forums.mydigitallife.net/threads/emulated-kms-servers-on-non-windows-platforms.50234/

利用KMS激活Windows和Office

一、安装
1、下载一键安装脚本(会自动git最新的vlmcsd),以下是在Ubuntu下

wget --no-check-certificate https://raw.githubusercontent.com/dakkidaze/one-key-kms/master/one-key-kms-debian.sh
wget --no-check-certificate https://raw.githubusercontent.com/dakkidaze/one-key-kms/master/one-key-kms-centos.sh

2、添加执行权限,运行脚本,然后输入确认安装

chmod +x one-key-kms-debian.sh
./one-key-kms-debian.sh

3、查看可以使用的命令

cd /usr/local/kms/
./vlmcsd -h

4、一般情况下一个kms服务器只要跑起来并能记录日志就可以了

./vlmcsd -L 0.0.0.0:1688 -l vlmcsd.log

二、其它
1、如果想看看这个程序都做了什么,可以加上-D参数,服务器会在前台运行,将日志信息输出到屏幕上。

./vlmcsd -D

2、停止运行使用pkill即可:
pkill vlmcsd
3、管理脚本(需配合一键安装脚本使用,如果不是使用一键安装脚本使用请手动更改脚本里的可执行文件路径)

wget --no-check-certificate https://raw.githubusercontent.com/dakkidaze/one-key-kms/master/kms.sh

4、有start,stop,restart,status四个功能,直接执行即可

./kms.sh start

激活相关:
用管理员身份运行命令行:
以Win10为例

slmgr.vbs -upk #卸载当前密钥
slmgr.vbs -ipk W269N-WFGWX-YVC9B-4J6C9-T83GX #安装密钥
slmgr.vbs -skms 192.168.200.200 #更改KMS激活服务器
slmgr.vbs -ato #马上激活
slmgr.vbs -dlv #显示激活信息

Office参考

https://github.com/luodaoyi/kms-server

【完】

一键安装脚本one-key-kms-debian.sh:

#! /bin/bash

#One-key-kms script by Dakkidaze

PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
clear
start(){
apt-get install gcc git make -y
mkdir /usr/local/kms
cd /usr/local/kms
git clone https://github.com/Wind4/vlmcsd.git
cd vlmcsd
make
cd bin
mv vlmcsd /usr/local/kms/kms
cd /usr/local/kms/
rm -rf ./vlmcsd/
mv kms vlmcsd
clear
echo "Succeeded."
echo "The executable file lies in /usr/local/kms/"
echo "Remember that the server is not running right now."
echo "Please use -h to find possible usage for the executable or visit vlmcsd on Github."
echo "https://github.com/Wind4/vlmcsd"
echo "Addtionally, you may want to get a script to manage it."
echo "In this case, you may download a script at the one-key-kms repository."
echo "Thanks for your using!"
echo "Dakkidaze "
}
echo "This script will automatically download and compile KMS Server program for you."
echo "For more information, please visit https://github.com/Wind4/vlmcsd"
echo "Scrpit written by Dakkidaze "
echo "READY TO START?"
read -p "y/n:" choice
case $choice in
"y")
start
;;
"n")
exit 0;
;;
*)
echo "Please enter y or n!"
;;
esac

管理脚本kms.sh#!/bin/bash
# Author: Dakkidaze

DAEMON=/usr/local/kms/vlmcsd
STAT=2
check_running(){
PID=`ps -ef | grep -v grep | grep -i "vlmcsd" | awk '{print $2}'`
if [ ! -z $PID ]; then
STAT=0
else
STAT=1
fi
}

do_restart() {
check_running
if [ $STAT = 0 ]; then
echo "Restarting KMS Server..."
kill $PID
elif [ $STAT = 1 ]; then
echo "Not started, starting now"
fi
$DAEMON -L 0.0.0.0:1688 -l vlmcsd.log
check_running
if [ $STAT = 0 ]; then
echo "Succeeded."
elif [ $STAT = 1 ]; then
echo "Failed."
fi
}
do_stop() {
check_running
if [ $STAT = 0 ]; then
echo "Shutting down KMS Server..."
kill $PID
check_running
if [ $STAT = 0 ]; then
echo "Failed."
elif [ $STAT = 1 ]; then
echo "Succeeded."
fi
elif [ $STAT = 1 ]; then
echo "Not running, no kill."
fi
}
do_status() {
check_running
if [ $STAT = 0 ]; then
echo "KMS Server is running."
elif [ $STAT = 1 ]; then
echo "KMS Server is not running."
fi
}

do_start() {
check_running
if [ $STAT = 0 ]; then
echo "KMS Server is already running."
exit 0;
elif [ $STAT = 1 ]; then
echo "KMS Server is not running, starting now..."
$DAEMON -L 0.0.0.0:1688 -l vlmcsd.log
fi
check_running
if [ $STAT = 0 ]; then
echo "Succeeded."
elif [ $STAT = 1 ]; then
echo "Failed."
fi
}

case "$1" in
start|stop|restart|status)
do_$1
;;
*)
echo "Usage: $0 start | stop | restart | status "
;;
esac