The tutorial is for those people, who wish to set up their own KMS server with CentOS/Debian/Ubuntu OS.
Requirements:
- CentOS 7 x64-bit
- 512 MB Memory
- 5 GB of Storage
Run the following commands to install the required RPMs on the server:
yum update -y && yum install curl wget nano screen git gcc -y
Once the required RPMs are installed on the server, download and compile vlmcsd from the GitHub repository:
git clone https://github.com/dartokloning/vlmcsd
cd vlmcsd && make && cd bin && ./vlmcsd && ./vlmcs
Once the compilation is completed, it will execute vlmcsd and slmsc binaries and the output should be:
$ ./vlmcs
Connecting to 127.0.0.1:1688 ... successful
Sending activation request (KMS V6) 1 of 1 -> 03612-00206-558-349390-03-12298-14393.0000-1742020 (3A1C049600B60076)
This means until here we have managed to compile and run the KMS server successfully!
Now, time to copy them ( vlmcsd and slmsc binaries ) to the /usr/bin directory:
cp vlmcsd /usr/bin
cp vlmcs /usr/bin
Let's start with the whitelisting the port 1688 with the firewalld and iptables so the KMS works perfectly:
firewall-cmd --zone=public --permanent --add-port=1688/tcp
firewall-cmd --reload
firewall-cmd --list-port
iptables -A INPUT -s 127.0.0.1 -d 127.0.0.1 -j ACCEPT
iptables -A INPUT -p tcp -m state --state NEW -m tcp --dport 1688 -j ACCEPT
iptables -L -n
Once it will be done too, we've to set the service for autostart! So, if we reboot the server, KMS starts automatically!
Create a file at /etc/init.d/ directory and open it with nano editor:
touch /etc/init.d/vlmcsd && nano /etc/init.d/vlmcsd
For CentOS 7 x64-bit server:
#!/bin/sh
#
# VLMCSD - this script starts and stops the KMS Server daemon
#
### BEGIN SERVICE INFO
# Run level information:
# chkconfig: 2345 99 99
# description: KMS Emulator in C
# processname: vlmcsd
### END SERVICE INFO
# Source function library
source /etc/init.d/functions
# Check that networking is up.
[ ${NETWORKING} ="yes" ] || exit 0
NAME=vlmcsd
SCRIPT=/usr/bin/vlmcsd
RUNAS=
PIDFILE=/var/run/$NAME.pid
LOGFILE=/var/log/$NAME.log
start() {
if [ -f "$PIDFILE" ] && kill -0 $(cat "$PIDFILE"); then
echo 'Service already running.'
return 1
fi
echo 'Starting service...'
local CMD="$SCRIPT -p $PIDFILE -l $LOGFILE -d"
su -c "$CMD" $RUNAS
echo 'Service started.'
}
stop() {
if [ ! -f "$PIDFILE" ] || ! kill -0 $(cat "$PIDFILE"); then
echo 'Service not running.'
return 1
fi
echo 'Stopping service...'
kill -15 $(cat "$PIDFILE") && rm -f "$PIDFILE"
echo 'Service stopped.'
}
status() {
echo "Checking $NAME service..."
if [ -f "$PIDFILE" ]; then
local PID=$(cat "$PIDFILE")
kill -0 $PID
if [ $? -eq 0 ]; then
echo "Running, the PID is $PID."
else
echo 'The process appears to be dead but pidfile still exists.'
fi
else
echo 'Service not running.'
fi
}
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status
;;
restart)
stop
start
;;
*)
echo "Usage: $0 {start|stop|status|restart}"
exit 1
;;
esac
exit 0
If you have installed KMS on a Ubuntu/Debian OS:
#!/bin/sh
#
# VLMCSD - this script starts and stops the KMS Server daemon
#
### BEGIN INIT INFO
# Provides: vlmcsd
# Required-Start: $local_fs $network $named $time $syslog
# Required-Stop: $local_fs $network $named $time $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Description: KMS Emulator in C
### END INIT INFO
NAME=vlmcsd
SCRIPT=/usr/bin/vlmcsd
RUNAS=
PIDFILE=/var/run/$NAME.pid
LOGFILE=/var/log/$NAME.log
start() {
if [ -f "$PIDFILE" ] && kill -0 $(cat "$PIDFILE"); then
echo 'Service already running.'
return 1
fi
echo 'Starting service...'
local CMD="$SCRIPT -p $PIDFILE -l $LOGFILE -d"
su -c "$CMD" $RUNAS
echo 'Service started.'
}
stop() {
if [ ! -f "$PIDFILE" ] || ! kill -0 $(cat "$PIDFILE"); then
echo 'Service not running.'
return 1
fi
echo 'Stopping service...'
kill -15 $(cat "$PIDFILE") && rm -f "$PIDFILE"
echo 'Service stopped.'
}
status() {
echo "Checking $NAME service..."
if [ -f "$PIDFILE" ]; then
local PID=$(cat "$PIDFILE")
kill -0 $PID
if [ $? -eq 0 ]; then
echo "Running, the PID is $PID."
else
echo 'The process appears to be dead but pidfile still exists.'
fi
else
echo 'Service not running.'
fi
}
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status
;;
restart)
stop
start
;;
*)
echo "Usage: $0 {start|stop|status|restart}"
exit 1
;;
esac
exit 0
Save the changes! After that we have to change the permissions of the service we created earlier:
chmod 755 /etc/init.d/vlmcsd
chown root.root /etc/init.d/vlmcsd
Then we register it so that this KMS server service can run automatically when the server boots, with the command:
chkconfig --add vlmcsd
chkconfig vlmcsd on
chkconfig vlmcsd start
Start the KMS service on your server:
systemctl start vlmcsd
Reboot the server once. Once it will be booted, run the command to verify vlmsd service is started or not:
ps ax | grep vlmcsd
Hurrah! You've set up a KMS on your server. Now your server can be used to activate MS products!