A hardened, opinionated Systemd service generator for modern Linux deployments.
mksvc creates secure-by-default .service files that lock down the filesystem, network and kernel capabilities. It manages the full lifecycle of a service configuration: generating the unit file, creating a dedicated system user, configuring log rotation and generating a setup script; all while intelligently preserving manual customizations on subsequent runs.
Download the latest binary from the Releases Page or install a prebuilt binary with one command:
curl -sL https://src.w2k.sh/mksvc/install.sh | shRun mksvc in the root of your project directory.
# Generate configs interactively
mksvc my-app /opt/my-app -i
# Apply the configuration (requires sudo)
sudo bash conf/setup.shThe tool creates a conf/ directory containing:
my-app.service: The Systemd unit file (Hardened).my-app.conf: Sysusers configuration to create themy-appuser/group.my-app_logs.conf: Logrotate configuration for efficient log management.setup.sh: An idempotent script to link units, create users, configure log rotation and fix file permissions.
mksvc is designed to run repeatedly without destroying your work.
- Managed Keys: Security attributes (e.g.,
ProtectSystem,SystemCallFilter) are owned by the tool. They are reset based on your interactive choices. - Custom Keys: Any key not managed by the tool is preserved. You can manually edit
conf/my-app.serviceto add environment variables or dependencies andmksvcwill respect them on the next run.
If you manually add this to conf/my-app.service:
[Service]
Environment=API_KEY=12345
TimeoutStartSec=600Running mksvc again will update the security sandbox settings but keep your Environment and TimeoutStartSec lines exactly as they are.
- Filesystem: Root is read-only (
ProtectSystem=strict). Working directory is read-only by default. - Process: No new privileges, restricted namespaces. Shells/subprocess capabilities are opt-in.
- Network: Offline/Airgapped by default (
PrivateNetwork=yes). Optional "Server Mode" for binding ports. - Kernel: Logs, modules and tunables are protected.
/devis private. - Memory:
MemoryDenyWriteExecuteenabled by default (WASM/JIT can opt-in).