在 ubuntu 18.04.1 架 kms 服務,啟用大量授權的系統
自建 kms 是使用 Open Source 的專案 vlmcsd,以下使用虛擬機測試,IP是在虛擬的IP區段。
環境 Hyper-V 中建立二台VM:
- ubuntu 18.04.1 (VM) IP: 192.168.123.101
- Windows Server 2019 (VM) IP: 192.168.123.102
搭載 kms
下載 vlmcsd 已編譯好的檔案
wget https://github.com/Wind4/vlmcsd/releases/download/svn1112/binaries.tar.gz
解壓縮
tar -zxvf binaries.tar.gz
切換至解壓縮的目錄
cd binaries
目錄中會有各個作業系統的資料夾
Android DragonFly FreeBSD Hurd iOS Linux MacOSX Minix NetBSD OpenBSD Solaris Windows
選擇需要的版本,這裡使用 Ubuntu 為例,將 `vlmcsd-x64-musl-static 複製為 kms,然後將 kms 移到 /usr/bin 資料夾。賦與 kms 的執行權限
cd Linux/intel/static
cp vlmcsd-x64-musl-static kms && sudo mv kms /usr/bin
chmod +x /usr/bin/kms
然後直接輸入 kms 即可運行服務
kms
執行的服務通訊埠為 1688,確認是否運行成功
netstat -an | grep 1688
設定防火牆放行 1688 port
使用 ufw
sudo ufw enable
# 查看狀態
sudo ufw status
# 允許 1688
# sudo ufw allow from <target> to <destination> port <port number=""> proto <protocol name="">
sudo ufw allow from 192.168.123.0/24 to any port 1688 proto tcp
使用 firewall-cmd 設定允許 1688 port 連入
firewall-cmd --zone=public --add-port=1688/tcp
firewall-cmd --zone=public --permanent --add-port=1688/tcp
firewall-cmd --reload
或
使用 iptables 設定允許 1688 port 連入,(註2)
iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 1688 -j ACCEPT
sudo iptables-save > ~/iptables.conf
sudo iptables-restore < ~/iptables.conf
建立開機啟動
# 建立資料夾
mkdir /usr/lib/systemd/system
# 編輯檔案
vim /usr/lib/systemd/system/kms.service
貼上以下內容
[Unit]
Description=KMS Service
After=network.target
Wants=network.target
[Service]
Type=forking
ExecStart=/usr/bin/kms
ExecStop=/usr/bin/killall kms
[Install]
WantedBy=multi-user.target
加入開機自啟動 kms.service
systemctl enable kms.service
啟動 kms
systemctl start kms.service
停止 kms
systemctl stop kms.service
或使用 rc.local 來開機自啟
vim /etc/rc.local
加入
/usr/bin/kms
激活金鑰
以下用操作皆使用管理員身份運行命令
啟用
解除原先金鑰 (如果安裝時序號是正確的不需此行)
slmgr.vbs -upk
選擇金鑰,請依照底下的金鑰列表作選擇 (如果安裝時序號是正確的不需此行)
slmgr.vbs -ipk xxxxx-xxxxx-xxxxx-xxxxx-xxxxx
設定KMS伺服器(我這裡kms架在 ubuntu 192.168.123.101:1688)
slmgr.vbs -skms 192.168.123.101
激活
slmgr.vbs -ato
顯示KMS相關資訊
slmgr.vbs -dlv
啟用 office 2010/2013/2016
if exist "C:\Program Files (x86)\Microsoft Office\Office14\ospp.vbs" (cd "C:\Program Files (x86)\Microsoft Office\Office14") else (cd "c:\Program Files\Microsoft Office\Office14")
if exist "C:\Program Files (x86)\Microsoft Office\Office15\ospp.vbs" (cd "C:\Program Files (x86)\Microsoft Office\Office15") else (cd "c:\Program Files\Microsoft Office\Office15")
if exist "C:\Program Files (x86)\Microsoft Office\Office16\ospp.vbs" (cd "C:\Program Files (x86)\Microsoft Office\Office16") else (cd "c:\Program Files\Microsoft Office\Office16")
cscript ospp.vbs /osppsvcauto
cscript ospp.vbs /sethst:192.168.123.101
cscript ospp.vbs /act
cscript ospp.vbs /dstatus
https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2012-R2-and-2012/jj612867(v=ws.11)
註1. 'Service' Command not found
The service
command is part of the sysvinit-utils package.
Install it with:
apt-get install sysvinit-utils
But most probably, it is already installed in /usr/sbin/service
.
If it's missing in your $PATH
, add this line to your ~/.bashrc
:
PATH=$PATH:/usr/sbin
註2. iptables: unrecognized service
檢查 iptables 是否安裝
sudo whereis iptables
出現 iptables: /sbin/iptables /usr/share/iptables /usr/share/man/man8/iptables.8.gz
表示已經安裝了 iptables。
如果沒有安裝,可以通過以下命令安裝
sudo apt-get install iptables
沒有留言:
張貼留言