Linux and servers · Intermediate · 17 min
Keep server time accurate with chrony and NTS
By Padding · Updated 18 Nov 2026
Ubuntu 26.04.1 LTS · chrony 4.8
You will have chrony syncing your Ubuntu 26.04 server over authenticated NTS, an extra time source of your choice, a step rule for VMs that get paused, and the option to serve time to your private network.
On this page
A server's clock drifts. The quartz crystal on a physical board gains or loses a few seconds a week, and a virtual machine that is paused, migrated or restored from a snapshot can come back minutes or hours behind. Most of the time nobody notices, until a TLS handshake fails, a one-time login code is rejected, or two servers' logs disagree about which event came first.
Ubuntu 26.04 handles this with chrony 4.8. Since Ubuntu 25.10, chrony is installed by default in place of systemd-timesyncd, and it talks to Ubuntu's time servers over NTS (Network Time Security). NTS adds TLS-based authentication to NTP, so a machine on the path between you and the time server cannot feed your server a false time without being caught.
In this tutorial you check what your server runs, see how a wrong clock breaks certificate checks, test a time server without touching your clock, add it as a source, read chrony's status output line by line, confirm the sources are authenticated, tune chrony for VMs, and open it up as a time server for your private network.
Step 1 · Check which time service your server runs
Servers installed fresh from 25.10 or later run chrony. A server upgraded from 24.04 may still run systemd-timesyncd, so look first:
timedatectl
systemctl status chrony --no-pagertimedatectl should show System clock synchronized: yes and NTP service: active. systemctl status chrony should show active (running). If the unit is not found, or is inactive while systemd-timesyncd runs, install chrony. apt removes systemd-timesyncd as part of the install, so you never have two clients fighting over the clock:
sudo apt update
sudo apt install -y chronyThen confirm the version and that it was built with NTS:
chronyd --versionCheck it worked
chronyd --version prints something like chronyd (chrony) version 4.8 (+CMDMON +NTP ... +NTS ...). The +NTS flag means this build can authenticate time servers. If you installed chrony just now, systemctl status chrony shows it running.
Step 2 · See what a wrong clock breaks
Before changing anything, it helps to see the failure you are preventing. A TLS certificate is valid only between its notBefore and notAfter dates, and the machine checking it uses its own clock to decide. The ISRG Root X1 certificate, which Let's Encrypt chains up to, ships with Ubuntu's ca-certificates package and is valid from June 2015 to June 2035. Check it at three points in time:
openssl x509 -in /etc/ssl/certs/ISRG_Root_X1.pem -noout -dates
openssl verify -CAfile /etc/ssl/certs/ISRG_Root_X1.pem /etc/ssl/certs/ISRG_Root_X1.pem
openssl verify -CAfile /etc/ssl/certs/ISRG_Root_X1.pem -attime "$(date -d 2015-01-01 +%s)" /etc/ssl/certs/ISRG_Root_X1.pem || echo "rejected: clock set before notBefore"
openssl verify -CAfile /etc/ssl/certs/ISRG_Root_X1.pem -attime "$(date -d 2036-01-01 +%s)" /etc/ssl/certs/ISRG_Root_X1.pem || echo "rejected: clock set after notAfter"-attime asks OpenSSL to pretend the clock reads a different time. The same certificate passes, then fails as certificate is not yet valid, then as certificate has expired. A server whose clock is badly wrong sees every HTTPS API it calls this way.
Two other things break with smaller errors:
- One-time codes. TOTP codes from authenticator apps change every 30 seconds. Many servers also accept the code just before the current one, so a clock that is a minute or two out starts rejecting correct codes, and users get locked out of SSH or admin panels that need a second factor.
- Log timelines. When you trace a request across a load balancer, an app server and a database, you line up their logs by timestamp. A two-second difference is enough to make an effect appear before its cause.
NTS itself has a chicken-and-egg problem: it uses TLS, so a clock that is years out cannot verify the time server's certificate. Ubuntu's default sources include a bootstrap server for that case, and chrony has a nocerttimecheck option for hardware with no battery-backed clock. Leave both as Ubuntu ships them unless you have that hardware.
Check it worked
You saw OK for the current time and two rejections, one with not yet valid and one with expired. The dates from -dates explain both.
Step 3 · Test a time server without touching your clock
chronyd -Q starts chrony as a one-off client, measures how far your clock is from the servers you give it, prints the result and exits. It does not change the clock and opens no ports, so you can run it next to the chrony service.
In the commands below, time.internal.example stands for your organisation's internal NTS server. Replace it with your server's name. If you do not have one, use time.cloudflare.com, a public server that supports NTS.
sudo chronyd -Q -t 30 'server time.internal.example iburst nts'The quoted argument is a chrony config line. When you pass lines like this, chronyd uses them instead of /etc/chrony/chrony.conf:
server time.internal.exampleis one named server. Usepoolinstead for a name that resolves to many servers.iburstsends a quick burst of requests at the start, so you get an answer in seconds rather than minutes.ntsmakes chrony fetch keys over TLS on TCP port 4460 first, check the server's certificate against the system's trusted CAs, and then authenticate every time packet.
-t 30 gives up after 30 seconds and exits with an error if no measurement arrived.
Check it worked
The output ends with a line like System clock wrong by 0.000214 seconds (ignored). (ignored) confirms nothing was changed. A few milliseconds is normal. If the command times out instead, check that the server name is right and that your firewall or provider lets out TCP 4460 as well as UDP 123. A certificate error in the output means the server's certificate is not trusted on this machine. For an internal server whose certificate comes from your own CA, copy that CA certificate into /usr/local/share/ca-certificates/ with a .crt ending and run sudo update-ca-certificates. chronyd -Q starts a fresh process, so it sees the new CA straight away; the running chrony service does not, which the next step deals with.
Step 4 · Add the server as a permanent source
Ubuntu's /etc/chrony/chrony.conf reads every file ending in .sources from /etc/chrony/sources.d/. The Ubuntu servers live in ubuntu-ntp-pools.sources there:
cat /etc/chrony/sources.d/ubuntu-ntp-pools.sources
grep -E '^(sourcedir|confdir)' /etc/chrony/chrony.confLeave that file alone, so package upgrades can update it, and add your own next to it. Replace time.internal.example with the server you tested:
sudo tee /etc/chrony/sources.d/internal.sources > /dev/null <<'EOF'
# Internal NTS time server, same data centre.
server time.internal.example iburst nts
EOF
sudo chronyc reload sourceschronyc reload sources makes the running service re-read the .sources files. No restart is needed, and the clock keeps its current state.
If you added your own CA with update-ca-certificates in the previous step, restart the service instead of reloading:
sudo systemctl restart chronyThe running chronyd reads the system's trusted CAs once, when its first NTS source starts, and keeps that list while any NTS source is in use. Ubuntu's NTS pool sources always are, so a reload leaves the old list in place and your server fails the TLS check with a certificate error, even though chronyd -Q worked. A restart reads the CAs again.
More sources are better than one: with three or more, chrony can spot a server that is wrong and outvote it. Keeping Ubuntu's pools alongside your own server gives you that.
If your servers are hosted in Africa, an internal or in-region server is worth adding. Round trips from Lagos or Nairobi to distant time servers are long and vary with load, and chrony's accuracy depends on that delay. The NTP Pool has an africa.pool.ntp.org zone, but the pool does not offer NTS, so a pool line there would be unauthenticated. Prefer an NTS server you or your provider runs in the region.
Check it worked
chronyc -N sourcestime.internal.example (your server's name) appears in the list beside the Ubuntu servers. A ? in the second column right after a reload means chrony has not heard back yet; give it half a minute. If it stays at ? with a Reach of 0 and you added a CA, restart chrony as above.
Step 5 · Read chronyc tracking line by line
chronyc tracking reports what the clock is doing now:
chronyc trackingThe output looks something like this:
Reference ID : 7F000001 (time.internal.example)
Stratum : 4
Ref time (UTC) : Thu Nov 26 09:41:12 2026
System time : 0.000012403 seconds fast of NTP time
Last offset : -0.000008112 seconds
RMS offset : 0.000231940 seconds
Frequency : 11.204 ppm slow
Residual freq : -0.002 ppm
Skew : 0.071 ppm
Root delay : 0.001934 seconds
Root dispersion : 0.000412 seconds
Update interval : 64.3 seconds
Leap status : NormalWhat each line tells you:
- Reference ID is the source chrony is following right now. All zeros,
00000000 (), means it is following nothing. - Stratum is how many hops your server is from a reference clock. A server synced to a stratum 3 server is stratum 4.
- Ref time is when chrony last took a measurement it used. If this is hours old, it has lost its sources.
- System time is the most useful line: how far the clock is off at this moment, and in which direction. chrony is correcting it slowly as you read.
- Last offset and RMS offset are the error at the last update and the average over recent updates. Steady sub-millisecond values mean healthy sync.
- Frequency is how fast this machine's clock runs wrong if left alone, in parts per million. 11 ppm slow is about one second a day. chrony saves it to its drift file so it starts with a good guess after a reboot.
- Residual freq and Skew are how uncertain that frequency estimate is. Small numbers are good.
- Root delay and Root dispersion add up delay and error all the way back to the reference clock. The
System timeoffset plus the root dispersion plus half the root delay is the worst case for how wrong your clock could be, assuming the reference clock itself is right. - Update interval is the time between clock updates. It grows to minutes once things settle.
- Leap status is
Normalwhen synced.Not synchronisedmeans chrony has no usable source.
Check it worked
Your output shows Leap status : Normal, a named source on the Reference ID line, and a System time under a few milliseconds. If you see Not synchronised, go back to the previous step's check and look for ? or x beside every source.
Step 6 · Check each source and confirm NTS is in use
chronyc sources -v adds a legend above the table explaining each column:
chronyc sources -vThe columns to read:
- First character is the kind of source:
^a server,=a peer,#a local reference clock. - Second character is chrony's verdict:
*the source it follows,+acceptable and combined with it,-acceptable but not combined,?unreachable or not yet measured,xa falseticker that disagrees with the majority,~too variable to use. - Poll is the interval between requests, as a power of 2 seconds:
6is 64 seconds,10is 1024. - Reach is an octal record of the last eight requests.
377means all eight were answered;0means none were. - LastRx is how long ago the last good reply came.
- Last sample is the measured offset, with the adjusted value in square brackets and the error margin after
+/-.
The table does not say whether a source is authenticated. authdata does:
sudo chronyc -N authdataCheck it worked
In sources -v, one line starts with ^* and the others mostly with ^+ or ^-, with Reach at or heading towards 377. In authdata, every Ubuntu server and your own server show NTS in the Mode column with a non-zero KeyID and KLen. A line with - as the mode is plain, unauthenticated NTP. If you see that for a source you meant to protect, check its line in sources.d ends with nts. If your server shows NTS but a KeyID of 0, the key exchange failed; after adding a CA, that almost always means the service still has its old CA list, so run sudo systemctl restart chrony.
Step 7 · Let VMs step the clock after a pause
chrony normally corrects the clock by slewing: running it slightly fast or slow until the error is gone, so time never jumps. Slewing has a limit, by default about 83 milliseconds per second. A VM paused for ten minutes would take two hours to catch up that way, and it is wrong for that whole time.
The makestep setting decides when chrony jumps instead. Ubuntu ships makestep 1 3: step if the error is over one second, but only in the first three updates after chrony starts. That covers a clock that is wrong at boot, but not a VM that is paused, snapshotted or live-migrated hours after boot.
For VMs, let chrony step whenever the error passes one second. A step backwards makes timestamps repeat, which can confuse software that assumes time only goes forwards, such as some databases and job schedulers. On a VM that is never paused, keep Ubuntu's default.
Put the change in /etc/chrony/conf.d/, which Ubuntu's config reads after the main file:
sudo tee /etc/chrony/conf.d/vm-step.conf > /dev/null <<'EOF'
# VM: step the clock whenever it is more than 1 s out, not just at start-up.
makestep 1 -1
EOF
sudo chronyd -p | grep makestepchronyd -p parses the whole configuration, including conf.d, prints it and exits. A typo shows up here as an error naming the file and line, before it can stop the service from starting. Then restart chrony to load the setting:
sudo systemctl restart chronyIf you resume a VM and want the clock fixed now, without waiting for the next update, step it by hand:
sudo chronyc makestepCheck it worked
chronyd -p | grep makestep prints two lines, makestep 1 3 from the main file and makestep 1 -1 from your drop-in. The later one wins. After the restart, systemctl status chrony shows active (running).
Step 8 · Serve time to your private network
chrony answers no clients until you allow them. If you have several servers on a private network, one chrony server can be their source, so only that machine needs outbound NTP and NTS. Replace 10.20.0.0/24 with your private subnet:
sudo tee /etc/chrony/conf.d/serve-lan.conf > /dev/null <<'EOF'
# Answer NTP requests from the private subnet only.
allow 10.20.0.0/24
EOF
sudo chronyd -p | grep allowKeep the allowed range to your private network. An NTP server open to the internet can be used to amplify traffic at someone else.
Open UDP port 123 to that subnet only in the firewall, then restart chrony so it starts listening:
sudo ufw allow from 10.20.0.0/24 to any port 123 proto udp
sudo systemctl restart chronyOn each client, add a .sources file pointing at this server's private address, for example server 10.20.0.5 iburst, and run sudo chronyc reload sources. This is plain NTP, which is reasonable on a network you control. To give LAN clients NTS as well, the server also needs a TLS certificate and key (the ntsservercert and ntsserverkey settings) and TCP port 4460 open, and clients add nts to their line.
Check it worked
chronyd -p prints allow 10.20.0.0/24. After the restart and a few minutes of client traffic, run sudo chronyc clients on the server. Each client's address appears with a count of NTP requests. On a client, chronyc sources lists 10.20.0.5 with a Reach that is not 0.
Next steps
- Go deeper into certificates, chains and expiry dates, which NTS and every HTTPS call depend on: /tutorials/understand-tls-certificates-and-chains-with-openssl
- Manage the firewall rule for UDP 123 alongside your others: /tutorials/set-up-ufw-firewall-ubuntu-26-04
- Read chrony's own log lines, such as source changes and clock steps: /tutorials/search-the-systemd-journal-with-journalctl
- If this is a new server, finish the rest of its first-day setup: /tutorials/initial-server-setup-ubuntu-26-04
Related tutorials
- Write safer Bash scripts with strict mode and trapsYou will build a small Bash release script that stops on the first error, says which line failed, survives file names with spaces and always removes its temporary files.
- Write least-privilege sudo rules with visudoYou will replace blanket sudo access with checked rule files in /etc/sudoers.d that let two operators restart one service and edit one file, give an automation account a password-free command list, and audit what every account can run.
- Upgrade a server from Ubuntu 24.04 LTS to 26.04 LTSYou will take a backed-up Ubuntu 24.04 server through do-release-upgrade to 26.04 LTS over SSH with a fallback login, then confirm services, repositories and language runtimes work on the new release.
Need this done for you?
Padding does this work for growing companies, from the first diagnosis to a system that keeps working.
Get new tutorials