Onion hidden service wont generate keys & hostname -HELP

Hello! I was trying to create an onion hidden service but, tor wont generate hostname and keys.
Here are the Steps which i did:

What i did:

  1. $ sudo vi /etc/tor/torrc
  2. uncommented HiddenServiceDir & HiddenServicePort

HiddenServiceDir /var/lib/tor/hidden_service/
HiddenServicePort 80 127.0.0.1:80

#HiddenServiceDir /var/lib/tor/other_hidden_service/
#HiddenServicePort 80 127.0.0.1:80
#HiddenServicePort 22 127.0.0.1:22

  1. Restarted tor service, $ sudo systemctl restart tor
  2. cat /var/lib/tor/hidden_service/hostname
    cat: /var/lib/tor/hidden_service/hostname: No such file or directory
    I went to /var/lib/tor directory and there was only “control_auth_cookie”

OS: Whonix

Sorry if this is a stupid question and if i’m wasting your time

Hello! I was trying to create a onion hidden service but, tor wont generate hostname and keys.
Here are the Steps which i did:

What i did:

  1. $ sudo vi /etc/tor/torrc
  2. uncommented HiddenServiceDir & HiddenServicePort

HiddenServiceDir /var/lib/tor/hidden_service/
HiddenServicePort 80 127.0.0.1:80

#HiddenServiceDir /var/lib/tor/other_hidden_service/
#HiddenServicePort 80 127.0.0.1:80
#HiddenServicePort 22 127.0.0.1:22

  1. Restarted tor service, $ sudo systemctl restart tor
  2. cat /var/lib/tor/hidden_service/hostname
    cat: /var/lib/tor/hidden_service/hostname: No such file or directory
    I went to /var/lib/tor directory and there was only “control_auth_cookie”

OS: Whonix

Sorry if this is a stupid question and if i’m wasting your time

Hello @rad and welcome to the forum!

First of all, delete the sentence Sorry if this is a stupid question and I’m wasting your time - at least in the future.

Your Tor daemon doesn’t have write access to the /var/lib/tor/hidden_service directory.

I’ll try not to give you the final solution, but the way to get there.
First run a grep tor on the /etc/passwd file. There you can easily find the system user Tor is running with.
Next, this user needs write permissions to the /var/lib/tor folder.

Alternatively, you can go a completely different way. This might help you in the future with other software. Write in the config instead of /var/lib/tor/hidden_service/ just /tmp/hidden_service/ - I think it should start. And then you can see what Tor is trying to create, who owns it and how the file permissions are set.

You can also find the username by running systemctl cat tor@.service and working your way through the configurations from there.

3 Likes