I'm running Tor 0.4.2.7 on Ubuntu Server 20.04, and I'm trying to create an onion service following the instructions here.
My torrc file looks like this:
HiddenServiceDir /home/tofol/hidden_service
HiddenServicePort 80 127.0.0.1:81
And I can connect to my web on port 81 successfully. I restart Tor using:
sudo service tor restart
Which restarts successfully. However, both the private_key and hostname files are missing from the hidden_service folder when I would expect them to be there. If the hidden_service folder isn't there when I restart Tor, Tor does not automatically create it either. Tor restarts correctly each time and produces no log file notices (I have log files enabled in torrc).
Can anybody please help me generate these two files?
EDIT:
rebooting my machine gave me some warnings in syslog which I resolved by running:
sudo chown -R debian-tor hidden_service
sudo chmod 700 hidden_service
Now syslog gives me:
systemd[1]: Starting Anonymizing overlay network for TCP...
tor[1034]: [notice] Tor 0.4.2.7 running on Linux with Libevent 2.1.11-stable, OpenSSL 1.1.1f, Zlib 1.2.11, Liblzma 5.2.4, and Libzstd 1.4.4.
tor[1034]: [notice] Tor can't help you if you use it wrong! Learn how to be safe at https://www.torproject.org/download/download#warning
tor[1034]: [notice] Read configuration file "/usr/share/tor/tor-service-defaults-torrc".
tor[1034]: [notice] Read configuration file "/etc/tor/torrc".
tor[1034]: Configuration was valid
tor[1037]: [notice] Tor 0.4.2.7 running on Linux with Libevent 2.1.11-stable, OpenSSL 1.1.1f, Zlib 1.2.11, Liblzma 5.2.4, and Libzstd 1.4.4.
tor[1037]: [notice] Tor can't help you if you use it wrong! Learn how to be safe at https://www.torproject.org/download/download#warning
tor[1037]: [notice] Read configuration file "/usr/share/tor/tor-service-defaults-torrc".
tor[1037]: [notice] Read configuration file "/etc/tor/torrc".
tor[1037]: [notice] Opening Socks listener on 127.0.0.1:9050
tor[1037]: [notice] Opened Socks listener on 127.0.0.1:9050
systemd[1]: [email protected]: Main process exited, code=exited, status=1/FAILURE
systemd[1]: [email protected]: Failed with result 'exit-code'.
systemd[1]: Failed to start Anonymizing overlay network for TCP.
Although service tor status
tells me Tor is running. /var/log/tor/notices.log doesn't give me anything. I still don't have private_key or hostname in my hidden_service folder.
/var/lib/tor/hidden_service
.journalctl -u [email protected]
give any more details. And since you're running it as a service, it may have hardening enabled. In this case it is probably not allowed to access files in your home directory. Runsystemctl cat [email protected]
and look for entries likeAppArmorProfile
,ReadOnlyDirectories
, orProtectHome
.