I read on many tutorials and websites that Tor will generate the hostname for you and put in a certain file, however it is not doing it and when I asked why, someone replied saying that is not what happens but that you need to create and configure it yourself. How do I do this?


Assuming the program that generated the hostname for you is working properly, it should give you 2 files, once called hostname and the other called private_key. Put the 2 files in one folder, for example /home/user/tor_private. The next step is to add a reference to this folder in your torrc file. Open your torrc file (it is in /etc/tor/torrc when you use some sort of GNU/Linux), and add the following two lines at the end of the file:

HiddenServiceDir /home/user/tor_private
HiddenServicePort 80

Finally, don't forget to tell your webserver (e.g. apache2) about the folder where you are putting your website files (your HTML files). Then, you'll have to restart Tor, and your webserver (e.g. apache2) afterwards, and your site will become accessible from the Tor network. The onion address of your website can be found in the hostname file you've put in /home/user/tor_private.

Few recommendations you should be aware of:

  1. For security reasons, it is not advised to run Tor using the root user. Instead create a user for Tor. Some Linux distros such as Debian automatically create a user called debian-tor when you install the Tor package. Use the Tor user (you created or already created by the system) to run Tor.
  2. Make sure only root or the Tor user have read access on the folder /home/user/tor_private. So the permissions on the folder should be 700.

  3. Don't put your website files inside /home/user/tor_private. That folder is only for storing your private key. Put them somewhere else accessible by the webserver.

  4. Don't share the private_key file with anybody. If anybody gets his hand on this file, you can take over your onion address and you'll loose ownership to your site!

| improve this answer | |
  • My issue had been that tor was not generating either of those, and I had nothing else to generate them with. I now solved the issue, thanks for trying to help. – CAllende Feb 1 '15 at 3:08
  • @CAllende Could you give us insights how you solved it? – Jens Kubieziel Mar 3 '15 at 0:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.