KMS服务器搭建及使用

KMS激活 操作系统 office(VOL)版激活
准备:Centos7操作系统,py-kms

<The rest of contents | 余下全文>

KMS服务器搭建

py-kms下载

https://github.com/matsuz/py-kms

Centos7安装运行py-kms的依赖包

root# yum install python-argparse

下载代码

git clone https://github.com/matsuz/py-kms

运行激活服务器

root# cd py-kms
root# python server.py

如果看到如下消息则证明安装成功

root# TCP server listenling at 0.0.0.0 on port 1688.

到此kms服务器搭建完毕,但是我们为了让其长期不间断运行我们还需要进行接下来的步奏


——- —- 华丽的分割线 —- ——-

长期运行配置

使用supervisor管理py-kms服务

拷贝py-kms文件到/usr/local/目录下

cp -r py-kms /usr/local/

安装supervisor

yum install python-setuptools
easy_install supervisor

生成默认配置文件

'echo_supervisord_conf> /etc/supervisord.conf'

编写supervisor脚本,加到/etc/supervisord.conf最后

[program:pykms]
command=python /usr/local/py-kms/server.py
autorestart=true
user=root

以deamon方式运行,执行

supervisord

——- —- 华丽的分割线 —- ——-

客户端测试

cd py-kms
python client.py -v 服务器ip

结果如下说明安装成功

Connecting to 服务器ip on port 1688...
Connection successful!
Sending RPC bind request...
RPC bind acknowledged.

——- —- 华丽的分割线 —- ——-

如果激活的时候出现如图错误


这是因为centos7 服务器的防火墙没有添加策略,需要添加规则。如果服务器放在了云端。云端的安全组,也需要添加一天允许1688端口连接的规则
这里我们只讨论,Centos7的防火墙设置

错误排查

Centos7 自带的防火墙是firewall。我不习惯用,就禁用掉,然后安装使用iptables防火墙规则

关闭firewall:

service firewalld stop
systemctl disable firewalld.service #禁止firewall开机启动

安装iptables防火墙

yum install iptables-service

编辑iptables防火墙配置 添加开放1688端口

vim /etc/sysconfig/iptables

下面是一个完整的配置文件内容:

Firewall configuration written by system-config-firewall

Manual customization of this file is not recommended.

*filter

:INPUT ACCEPT [0:0]

:FORWARD ACCEPT [0:0]

:OUTPUT ACCEPT [0:0]

-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT

-A INPUT -p icmp -j ACCEPT

-A INPUT -i lo -j ACCEPT

-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT

-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT

-A INPUT -m state --state NEW -m tcp -p tcp --dport 1688 -j ACCEPT

-A INPUT -j REJECT --reject-with icmp-host-prohibited

-A FORWARD -j REJECT --reject-with icmp-host-prohibited

COMMIT

wq!保存退出

service iptables start #开启
systemctl enable iptables.service #设置防火墙开机启动

##激活演示
以管理员权限运行CMD命令提示符
输入命令

slmgr /ipk xxxxxxxxxxxxxxxxxxxx (对应版本的KMS激活密钥 参考下面附录1)
slmgr /skms 服务器ip或者域名(如 kms.damowang.cn)
slmgr /ato 


系统成功激活


附录1:https://technet.microsoft.com/en-us/library/jj612867.aspx

激活office

cscript "C:\Program Files (x86)\Microsoft Office\Office14\OSPP.vbs" /sethst: xxxxxx(xxxxxx用kms域名或者ip地址代替)
cscript "C:\Program Files (x86)\Microsoft Office\Office14\OSPP.vbs" /ato

注意激活office必须是VOL版本而不能是Retail版本。如果激活出现错误,注意查看版本,路径是否正确,ip是否正确可用。激活用的密钥是否正确,若提示密钥无效尝试更换office密钥。

cscript ospp.vbs /dstatus

显示当前已安装产品密钥的许可证信息。可以查看到自已安裝的版本有多少个序列号。

cscript ospp.vbs /unpkey:xxxxx

卸载已安装的产品密钥。后面的数字是密钥的最后5位数。

此时再执行cscript ospp.vbs /dstatus发现产品密钥已经没有了,我重新进行导入。

cscript ospp.vbs /inpkey:xxxxx…… (xxxx代表对应版本的密钥可自己在网上找,也可以在微软官网 )

安装、替换现有的产品密钥。和上面的过程刚好相反。

cscript ospp.vbs /sethst:x.x.x.x

设置KMS主机名。一般为IP地址。

cscript ospp.vbs /act

激活当前安装的Office。

如果office曾经用其它的KMS服务器激活。一定要用

cscript OSPP.vbs /remhst

移除kms主机,再执行以上命令
错误排查以及对应KMS KEY 参见附录2


附录2:https://technet.microsoft.com/zh-cn/library/ee624355(v=office.14).aspx

文章目录
  1. 1. KMS服务器搭建
    1. 1.1. py-kms下载
    2. 1.2. Centos7安装运行py-kms的依赖包
    3. 1.3. 下载代码
    4. 1.4. 运行激活服务器
    5. 1.5. 如果看到如下消息则证明安装成功
  2. 2. 长期运行配置
    1. 2.1. 使用supervisor管理py-kms服务
    2. 2.2. 安装supervisor
    3. 2.3. 生成默认配置文件
    4. 2.4. 编写supervisor脚本,加到/etc/supervisord.conf最后
    5. 2.5. 以deamon方式运行,执行
  3. 3. 客户端测试
    1. 3.1. 结果如下说明安装成功
  4. 4. 如果激活的时候出现如图错误
    1. 4.1. 错误排查
    2. 4.2. 关闭firewall:
    3. 4.3. 安装iptables防火墙
    4. 4.4. 编辑iptables防火墙配置 添加开放1688端口
    5. 4.5. wq!保存退出
,