Resources · Security guides · Security guide
Keep the server clock in sync
TLS, signed requests, TOTP codes and log timelines all depend on an accurate clock. Run one time-sync service and check that it is synchronised.
Check command
timedatectl show -p NTPSynchronized --value
Copied.
A drifting clock breaks things that look unrelated: TLS handshakes fail when certificates look not-yet-valid, signed requests (AWS, Stripe webhooks, PortGate heartbeats) are rejected for clock skew, TOTP 2FA codes stop matching, and logs from two servers cannot be lined up during an incident.
Check the current state
timedatectl
timedatectl show -p NTPSynchronized --value
System clock synchronized: yes and yes from the second command are what you want.
Use one time-sync service
Ubuntu and Debian ship systemd-timesyncd, which is enough for most servers:
sudo timedatectl set-ntp true
For hosts that need tighter accuracy, or that run as an NTP source for others, use chrony instead. Install one, not both:
sudo apt install chrony
sudo systemctl enable --now chrony
chronyc tracking
chronyc tracking shows the current offset. A few milliseconds is normal.
Containers and VMs
Containers use the host's clock, so fix it on the host. On some hypervisors a paused or migrated VM jumps in time. chrony handles large corrections better than timesyncd there (makestep 1 3 in its config allows stepping during the first updates).
Time zones
Keep servers in UTC (sudo timedatectl set-timezone UTC) and convert in the app or the dashboard. Mixed time zones across servers are a common reason logs do not line up.