Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Safer systemd service file #1221

Open
gvalkov opened this issue Jan 23, 2025 · 0 comments
Open

Safer systemd service file #1221

gvalkov opened this issue Jan 23, 2025 · 0 comments

Comments

@gvalkov
Copy link

gvalkov commented Jan 23, 2025

Hello,

The example systemd service file is not particularly secure. It would be useful to have a more elaborate example and directions on how to further secure it (i.e. systemd-analyze security) :

[Unit]
Description=Warpgate
After=network.target
StartLimitIntervalSec=0

[Service]
ProtectSystem=strict
PrivateTmp=true
PrivateUsers=True
PrivateDevices=true
ProtectKernelTunables=true
ProtectKernelModules=true
ProtectKernelLogs=true
ProtectControlGroups=true
ProtectProc=noaccess
ProtectHostname=true
MemoryDenyWriteExecute=true
RestrictAddressFamilies=AF_INET AF_INET6 AF_UNIX  # AF_UNIX is needed by sd_notify
LockPersonality=true
ProtectClock=true
NoNewPrivileges=true
RestrictNamespaces=true
RestrictRealtime=true
RestrictSUIDSGID=true
SystemCallArchitectures=native
CapabilityBoundingSet=

# You may want to modify the following to fit your environment.
ReadWritePaths=/opt/warpgate 
ExecPaths=/usr/local/bin/warpgate
SocketBindAllow=ipv4:8888
SocketBindAllow=ipv4:8888
SocketBindDeny=any
User=warpgate

Type=notify
UMask=0027
Restart=always
RestartSec=5
ExecStart=/usr/local/bin/warpgate --config /opt/warpgate/config.yaml run

[Install]
WantedBy=multi-user.target

The above results in a systemd-analyze security score of 2.9 OK.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant