KMS auto-activation on Raspberry Pi 3 (raspberrypi 3B)

Source: Internet
Author: User
Keywords sql server raspberry pi 3 raspberry pi 3 sql server cloud server raspberry pi 3 raspberry pi 4 kms
Tags nslookup pscp

1. hostname Please change from default Raspberrypi to

sudo nano /etc/hostname

Please change the raspberrypi in the file to

2. Change the IP address of the Raspberry Pi to static, in this case, the gateway exits to

sudo nano /etc/dhcpcd.conf

At the bottom of the document, add the following settings:

interface eth0static ip_address= routers= domain_name_servers=

3. Resolve the host itself to

sudo nano /etc/hosts

Comment out the record about Raspberrypi and add the following line:

4. Restart Pi

5. In this case, upload the relevant file using the Pscp.exe provided by putty in the Windows system.

First, establish a KMS server
There are a number of ways to build a KMS server on Raspberry Pi 3, and here is a relatively simple and complex one.

Please choose one of them in (i) and (b)!

(a) Use a KMS server file that has been edited.
The file was written by the Hotbird64 God.
To download, you need to register.
After downloading the unpacked files, we need the files as:


Rename the file to: vlmcsdpi

1. Create a new KMS folder

mkdir /home/pi/kms

2. Uploading KMS files
Under Win, start cmd or PowerShell, enter the Pscp.exe folder, I will pscp.exe and vlmcsdpi are placed under the E:\putty.

cd e:\puttypscp e:\putty\vlmcsdpi [email protected]:/home/pi/kms/

After entering the pi password, the upload is successful.

3. Give execution permission

chmod 777 /home/pi/kms/vlmcsdpi

4. Set boot from Start

sudo nano /etc/rc.local

Join before exit 0:

/home/pi/kms/vlmcsdpi -l /var/log/vlmcsd.log > /dev/null 2>&1

5. Start the service:

/home/pi/kms/vlmcsdpi -l /var/log/vlmcsd.log

The log file is:/var/log/vlmcsd.log

6, Stop the service:
Find the process number and kill it.

sudo ps -ef | grep vlmcsdpisudo kill -s 9 进程号

This method is built quickly and easy to upgrade. If the HOTBIRD64 the new version, upgrade as long as the new version of the file can be replaced.

(ii) Use of py-kms to build a KMS server
1. Install git

sudo apt-get install git

2. Download the py-kms in the Pi home directory:

git clone

Because the pi comes with Python, the initial test can be done after the download:

cd py-kms  python


The prompt for success. Press CTRL + C to exit.

3. Use supervisor to ensure long-term operation of KMS services:

Now put py-kms into/usr/local/:

sudo cp -r py-kms /usr/local/

Install Supervisor:

Write a configuration file

mv /etc/supervisord.conf /etc/supervisord.conf.baksudo nano /etc/supervisord.conf

The contents are:

; /etc/supervisord.conf
file = /var/run/supervisord.sock
chmod = 0777
chown = root: root

port = *: 9001
username = pi
password = yourpassword

; Must match the setting in ‘unix_http_server’
serverurl = unix: ///var/run/supervisord.sock

logfile = / var / log / supervisord.log; (main log file; default $ CWD / supervisord.log)
logfile_maxbytes = 50MB; (max main logfile bytes b4 rotation; default 50MB)
logfile_backups = 10; (num of main logfile rotation backups; default 10)
loglevel = info; (log level; default info; others: debug, warn, trace)
pidfile = / var / run /; (supervisord pidfile; default
nodaemon = true; (start in foreground if true; default false)
minfds = 1024; (min. avail startup file descriptors; default 1024)
minprocs = 200; (min. avail process descriptors; default 200)
user = root; (default is current user, required if root)
childlogdir = / var / log /; (‘AUTO’ child log dir, default $ TEMP)

[rpcinterface: supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface: make_main_rpcinterface

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

After writing the configuration file, execute:

sudo chmod 777 /var/run  
sudo chmod 777 /var/log  
sudo touch /var/run/supervisor.sock
sudo chmod 777 /var/run/supervisor.sock

Start Supervisor:

sudo supervisor

4. Enable the Supervisor to boot:

sudo nano /etc/rc.local

Join before exit 0:

After restarting the PI, see if the process starts normally:

Under normal circumstances, the should be running.
Quit with quit.

5. Test the KMS server:

cd  /usr/local/py-kmspython -v

The test results are:

Connecting to on port 1688...  
Connection successful!  
Sending RPC bind request...  
RPC bind acknowledged.

is a success.

Second, make the machine in the LAN can activate itself
Before you begin this step, make sure that all other DHCP servers on the LAN are down!

1. Create a/etc/resolv.dnsmasq.conf file

sudo cp  /etc/resolv.conf /etc/resolv.dnsmasq.confsudo nano /etc/resolv.dnsmasq.conf

To delete the original contents of the file, create the following:


2. Installing the software for testing DNS

sudo apt-get install dnsutils

3. Install a lightweight DNS forwarding server, DHCP server

sudo apt-get install  dnsmasq

4. Configure DNSMASQ:

sudo mv /etc/dnsmasq.conf /etc/dnsmasq.conf.baksudo nano /etc/dnsmasq.conf

The configuration content is as follows:

#Specify the upstream server address, determined by the contents of the /etc/resolv.dnsmasq.conf file
resolv-file = / etc / resolv.dnsmasq.conf
# Strictly follow the order in resolv.dnsmasq.conf
#Listening address
listen-address =,
#Address pool settings
dhcp-range =,,,6h
#Set LAN suffix name, important, please be sure to set
domain =
#Designated gateway (route exit)
dhcp-option = 3,
# dhcp-option = option: router,
#Specify the DNS assigned to the client when the address is distributed, in addition to the local dns server address, other dns addresses are added for insurance purposes
dhcp-option = option: dns-server,,
# server =
#Usually used to prohibit access to a domain name that does not exist, to prevent it from jumping to the operator's advertising site.
bogus-nxdomain =
#Set kms server response
srv-host = _vlmcs._tcp,, 1688,0,100
#Enable log recording, specify the log file path and file name
log-facility = / var / log / dnsmasq.log

To restart the DNS service:

sudo service dnsmasq restart

5. The test command is as follows: (Test in Windows system, be sure to ensure that other DHCP servers on the network have been shut down and the Windows system has auto-get address enabled)
Under Win, start Cmd or powershell

ipconfig  /renew
nslookup -type=srv _vlmcs._tcp
nslookup -q=srv

The following 2 commands must all be fed back with the same result:

Address: SRV service location:
           priority = 0
           weight = 100
           port = 1688
           svr hostname = internet address = 

KMS auto-activation on Raspberry Pi 3 (raspberrypi 3B)

Alibaba Cloud Hot Products

Elastic Compute Service (ECS) Dedicated Host (DDH) ApsaraDB RDS for MySQL (RDS) ApsaraDB for PolarDB(PolarDB) AnalyticDB for PostgreSQL (ADB for PG)
AnalyticDB for MySQL(ADB for MySQL) Data Transmission Service (DTS) Server Load Balancer (SLB) Global Accelerator (GA) Cloud Enterprise Network (CEN)
Object Storage Service (OSS) Content Delivery Network (CDN) Short Message Service (SMS) Container Service for Kubernetes (ACK) Data Lake Analytics (DLA)

ApsaraDB for Redis (Redis)

ApsaraDB for MongoDB (MongoDB) NAT Gateway VPN Gateway Cloud Firewall
Anti-DDoS Web Application Firewall (WAF) Log Service DataWorks MaxCompute
Elastic MapReduce (EMR) Elasticsearch

Alibaba Cloud Free Trail

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.