Syncronizing time through tor

Hi everyone
so I am trying to build a tor-only system using a RaspberryPi Zero 2W. It shall eventually host a little onion service. It is more about building it then it having a great use. I like the idea of having a portable pocket size onion server even though there are maybe better ways of hosting.

I use apt-transport-tor, route dns and environment through socks5h proxys and the set the firewall rules on nftables to only accept outgoing connection from the user debian-tor (and loop).
It works really nice however I am struggling with one last issue: the clock.
This is especially bad since the Pis by default don’t have a battery powered hardware clock. So time freezes every time they are shut down.

I found surprisingly little on how to synchronize time through tor.
Tails and Whonix have a very similar way to do it by connecting to websites and use the timestamp of this connection to guess the right time.

Whonix: Sdwdate
There is a little bit of documentation but it is designed for the KicksecureOS and mainly for VM based Systems like Whonix or Qubes.

Tails: Custom htpdate fork
I would like to apply something like that since Tails has the similar issue with the missing clock as the pi does. However I could not find anything on how to apply it outside Tails.

I am worried that if I just start customize myself I might create some unique fingerprint. I also feel like I am trying to reinvent the wheel. I cannot be the only one trying to sync time through tor. Maybe it is so obvious and I just don’t see it.
So if anyone could help me out or point me in the right direction it would be highly appreciated!

For now I am okay with setting the time after boot manually (if needed) to be able to connect with tor but then the clock should be synced automatically.

Thanks at advance for your help!

2 Likes

I know it doesn’t answer quite the question you asked, but I’ve resolved similar Pi real-time clock issues with low-cost hardware solutions like this one: Mini RTC Module for Raspberry Pi - The Pi Hut
Battery powered, keeps time while the Pi is powered down, seamlessly provides wall-clock time to Pi when it comes back up.

1 Like

I found a way to make it work combining htpdate and privoxy. Privoxy can route the http or https traffic from htpdate through my socks5h proxies.
I added a timer in systemd to start the htpdate.service a bit later so after boot tor has some time to connect.
I set it up that I need a working Tor connection to sync time. So I need a more or less correct time to start with. Your idea with the battery would fit in nice there. I want to keep the Pi Zero pocket size for now so I have to set time manually and then have like a 23 hours window where I can still connect to Tor before the clock it too much off.

1 Like