Skip to content

Instantly share code, notes, and snippets.

@mattrude
Last active February 6, 2019 19:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattrude/07edf38d965d6106b95094d8df4fe36d to your computer and use it in GitHub Desktop.
Save mattrude/07edf38d965d6106b95094d8df4fe36d to your computer and use it in GitHub Desktop.
Adding systemd services for SKS-Keyserver on Ubuntu 18.04 LTS

Adding systemd services for SKS-Keyserver on Ubuntu 18.04

This page will walk you threw installing the sks-keyserver systemd services on a Ubuntu 18.04 LTS, thou it will most likely work with any systemd server.

The systemd services provided on this page will auto start the sks daemon when the server is booted up, and will restart the daemon if it dies for some reason.

Note, this page assumes your sks daemon is located at /usr/local/bin/sks and your key directory is /var/lib/sks.

User Setup

First confirm you have the debian-sks user and group added to your system. If you do not, you may add them with the following command:

adduser --system --group --home /var/lib/sks --disabled-login debian-sks

Systemd Services Install

Now, download the needed service files and add them to your /etc/systemd/system/ directory. Note, these config assume the sks daemon lives at /usr/local/bin/sks if yours is in a diffrent spot, you will need to update both files to point to your install locaction.

The SKS DB Service

curl -Ls "https://gist.githubusercontent.com/mattrude/07edf38d965d6106b95094d8df4fe36d/raw/sks-db.service" \
    -o /etc/systemd/system/sks-db.service

The SKS Recon Service

curl -Ls "https://gist.githubusercontent.com/mattrude/07edf38d965d6106b95094d8df4fe36d/raw/sks-recon.service" \
    -o /etc/systemd/system/sks-recon.service

Systemd Services Setup

After you have the services installed, you may enable the services.

systemctl daemon-reload
systemctl enable sks-db.service
systemctl enable sks-recon.service

Managing the SKS-Keyserver via Systemd

Starting the SKS-Keyserver

systemctl start sks-db sks-recon

Restarting the SKS-Keyserver

systemctl restart sks-db sks-recon

Stopping the SKS-Keyserver

systemctl stop sks-db sks-recon

Checking the status of the SKS-Keyserver

systemctl status sks-db sks-recon

Here is the output:

● sks-db.service - SKS-Keyserver DB Instance
   Loaded: loaded (/etc/systemd/system/sks-db.service; enabled; vendor preset: enabled)
   Active: active (running) since Tue 2019-02-05 20:55:22 UTC; 1h 45min ago
 Main PID: 8445 (sks)
    Tasks: 1
   Memory: 1016.3M
      CPU: 15min 5.827s
   CGroup: /system.slice/sks-db.service
           └─8445 /usr/local/bin/sks db

● sks-recon.service - SKS-Keyserver Recon Instance
   Loaded: loaded (/etc/systemd/system/sks-recon.service; enabled; vendor preset: enabled)
   Active: active (running) since Tue 2019-02-05 20:55:21 UTC; 1h 45min ago
 Main PID: 8442 (sks)
    Tasks: 1
   Memory: 131.7M
      CPU: 19.833s
   CGroup: /system.slice/sks-recon.service
           └─8442 /usr/local/bin/sks recon
[Unit]
Description=SKS-Keyserver DB Instance
After=network.target
[Service]
Type=simple
User=debian-sks
Group=debian-sks
WorkingDirectory=/var/lib/sks
ExecStart=/usr/local/bin/sks db
Restart=on-failure
RestartSec=5
[Install]
WantedBy=multi-user.target
[Unit]
Description=SKS-Keyserver Recon Instance
Before=network.target
Wants=network.target
[Service]
Type=simple
User=debian-sks
Group=debian-sks
WorkingDirectory=/var/lib/sks
ExecStart=/usr/local/bin/sks recon
Restart=on-failure
RestartSec=5
[Install]
WantedBy=multi-user.target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment