0

The only way I could get a working clock on Debian is by using NTP to sync the clock as described here.

Is there a way to have a reliably accurate clock without NTP and without any Internet connection?


After preventing various autostarting software, blocking kdeconnectd from getting launched (in KDE), and only allowing needed Internet connections in the nftables firewall sudo lsof -i shows me ntpd is nearly the only Internet connection left besides Firefox.

I'm interested in better ways than using NTP in general but I'd also like to minimize attack surfaces and even without any potential vulnerabilities and no log-keeping by the NTP servers, having over a dozen of concurrent Internet connections whenever using the computer and being online is a risk to anonymity and privacy (correlating online time data).

Moreover, being required to use NTP to make the clock work means you're dependent on having an internet connection for a working clock which is another reason I'm curious about this.

It would be strange if this is not possible with computers when this been working for decades with often very little offset for wristwatches and so on.

Maybe this is possible using some cheap hardware you can plug on a mainboard or various specific mainboards. I'm most interested in a way to have a local time-source not requiring any radio signals that is low-cost (you can't plug the Deep Space Atomic Clock onto your mainboard, nor a mechanical clock which can sometimes have <5 s offset for a decade).

4
  • 3
    Too much to unpack here, but ntp has no potential for risking anonymity. Anyways, sure, a GPS receiver works completely offline and gives you high-accuracy time. You don't need that though, just like your wristwatch, any PC can keep the time in its own, so it's not even clear whether you have a problem that needs solving. May 11 at 21:52
  • I should have made it clearer that this is not a large risk. It could even have no risk at all, what I was saying is that it could have risks because you could for example correlate which times a server received requests from certain IPs and so on with other data that you have or can get (certainly nothing to worry about for most). No reason to downvote the question. If that is the case why does my clock get a multi-minute offset without NTP? And that is on multiple Debian11/KDE machines, not just one, as described in the linked unanswered question.
    – mYnDstrEAm
    May 11 at 21:58
  • 1
    Well, if you do not want to use NTP, consider using PTP (Precision Time Protocol)
    – fpmurphy
    May 12 at 4:14
  • (Moved from answer to comment) Non-TCP/IP sources of accurate time were discussed a lot in the early 2000s, but not so much anymore. I did a search in Google for the words linux radio signal clock and found older discussions about getting time signals from GPS receivers or from the broadcast station WWV, operated by NIST in the USA as a public service for accurate time. Since the discussions were older, some of their info may be obsolete. Since I haven't followed the topics for 15+ years, I don't have a specific recommendation to make.
    – Sotto Voce
    May 21 at 17:25

1 Answer 1

3
  • A pc with an accurate real time hardware clock can keep time accurately. Unfortunately, a lot of motherboards seem to have inaccurate hardware clocks.

  • ntpd doesn't need internet. You can also get an external hardware clock and it will sync to it. For instance, GPS is popular for this purpose, and is what a lot of stratum 1 ntp servers use.

  • If your pc has a stable but uncalibrated clock, you can use the adjtimex command line tool to calibrate it. (Check the man page for the procedure.) You may need to run it several times over a day or a week to reduce your desired rate of drift. (Again, you need an external time source for this -- like a clock with a second hand.) Note that this won't work if your clock is unstable (e.g., it drifts at a rate that varies with temperature).

While I think it is wildly paranoid to think that ntp is any kind of privacy risk, there are other reasons for wanting this. For instance, an unstable network connection can cause ntp to crash if the clock drifts too much while the network is down. And I've had instances where I needed to take a computer into the field where no internet connection was available but I needed very precise time. (GPS is your best bet in that situation.)

There are plenty of guides online on how to set up ntp with a gps. NTP documentation has a list of supported GPS's. Basically, you want a GPS with a serial port to output the time, and a 1.0000000PPS logic output pin and a way to read that pin accurately. I use a raspberry pi with a gps hat that does this and then talk to the pi over the local network, but I've done it directly on the pc in the past.

9
  • •If NTP doesn't need Internet then I'm interested in both the best option to use NTP without Internet and a way to get an accurate clock without NTP and Internet.•This is useful but it drifts by minutes on multiple machines without NTP/Internet.•I made it clearer in a comment above why I mentioned privacy, I'd simply like to have fewest Internet connections as possible if they aren't needed even if the risk is low and you could correlate online times (via NTP Internet connections to these servers). I also said this is only one of several reasons so a misunderstanding. Any non-GPS way/hardware?
    – mYnDstrEAm
    May 11 at 22:28
  • 2
    I've already stated that ntp+gps is your best bet without internet. (And maybe even with internet.) Without ntp, your best bet is adjtimex and/or resetting the clock manually when it drifts too much.
    – user10489
    May 11 at 22:31
  • 1
    "it drifts by minutes on multiple machines" in my experience this is extremely unusual. It sounds to me like you've started some sort of synchronisation to an external time source and then you've forcibly changed the local time, leaving the local system thinking the clock is wildly more inaccurate than it actually is. The result is that the kernel over-disciplines the clock in the opposite direction May 11 at 23:36
  • No, I haven't done anything in regards to the clock. I only did some measures to increase security and privacy such as uninstalling geoclue and implementing some lynis system audit recommendations. This happened repeatedly with multi-minute offset on multiple machines with the wrong time staying like that for long. I most likely installed openntpd because of the clock drift, not because lynis recommended it (if I used l earlier). I don't think a dysfunctional or firewall-disallowed openntpd or ntp caused it even if I had installed that on both machines before (didn't notice at first).
    – mYnDstrEAm
    May 12 at 10:28
  • 1
    The classic ntpd linux code has harcoded in it to crash if the clock drifts too much. The max drift is like half a second or a few seconds or something. So if you lose your time source and your clock drifts, ntpd will crash when it regains the source.
    – user10489
    May 20 at 14:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .