Disclosure: at the end of this post I link to a paid checklist I made ($9). Everything below is free to use without it. This post was drafted with AI assistance and reviewed by me.
I run a small ASP.NET Core app directly on an Ubuntu VPS with systemd and nginx, without containers. These are the points that cost me the most time:
MemoryDenyWriteExecute=truestops .NET from starting. The JIT needs memory that is writable and executable. Leave it off for .NET services.Without
SetApplicationName, every deploy signs users out. With areleases/<id>layout the content root changes each release, and Data Protection treats it as a new app. Fix the name:
builder.Services.AddDataProtection() .SetApplicationName("example") .PersistKeysToFileSystem(new DirectoryInfo("/var/lib/example/keys")); EnvironmentFile=is read by systemd (PID 1), not by your service user. Make itroot:root 0600; the service needs no access to it.Measure hardening. Run
systemd-analyze security example.servicebefore and after; the exposure score shows what each setting actually changed.Narrow syscall filters need two exceptions for .NET. Blocking
@resourcesalso blockssched_setaffinityandsched_setscheduler, which the runtime uses:
SystemCallFilter=~@privileged @resources @keyring SystemCallFilter=sched_setaffinity sched_setscheduler "Listens on loopback" is a claim until you test it from another machine. After every deploy, check from outside that the app port is closed.
"System restart required" does not go away by itself. Kernel updates wait for a reboot; plan maintenance windows instead of postponing.
Never put database admin tools or dashboards behind the public reverse proxy. Use an SSH tunnel for administration.
I turned the full setup (unit file, hardening, nginx, Data Protection, rollback, recurring checks) into a 12-page checklist: ASP.NET Core on Ubuntu: systemd Deployment Checklist ($9).

