4

I am trying to run hidden services with tor. But when I start it just using tor I get this error:

... is not owned by this user (user, 1000) but by debian-tor (118). Perhaps you are running Tor as the wrong user?

When I run it using sudo tor:

... is not owned by this user (root, 0) but by debian-tor (118). Perhaps you are running Tor as the wrong user?

And when I try sudo service tor start it doesn't show any errors but it still doesn't works.

I also added User debian-tor to torrc. But than I get the error Directory /root/.tor cannot be read: Permission denied when I run it as root(sudo tor). And the error Directory ... cannot be read: Permission denied when I run it with tor or as service.

When I change the owner of the directory to root I can start it with sudo tor but still not with sudo service tor start, I also don't think it is save tor run it with the root user.

I am using Debian Jessie. Does anyone know how I can fix this? I want to run tor as a service.

EDIT: I installed centos and got the exact same error...

But i found out when I use /var/lib/tor/ as directory it works! But when I use /var/lib/tor/hidden_service/ (With user _tor as owner) I still have an permission error. I tried to add ReadWriteDirectories to tor.service with /var/lib/tor/hidden_service/ as directory. But that also doesn't work.

2
  • For your second example, have you edited anything to allow you to run as root? (I was under the impression that such a thing would be blocked due to safety concerns.) How did you install Tor in the first place? By downloading the bundle from the Tor site, or from a repository? Feb 9, 2016 at 22:58
  • @RichardHorrocks I followed option 2 from this website. torproject.org/docs/debian.html.en When I start it as root it does say that i probably shouldn’t do it. But it works.
    – Jan Wytze
    Feb 10, 2016 at 13:06

4 Answers 4

4

When you want to start via command line you need to do it as the correct user. As the message says it expects debian-tor. So call Tor in the following way:

sudo -u debian-tor tor
2
  • I forgot to mention it, but I want to run tor as a service. I just tried this command and I get an permission error.
    – Jan Wytze
    Feb 10, 2016 at 13:02
  • 1
    I was just stuck with this same problem, and this solution worked for me perfectly. I'd like to add to this that to see what user might be required for tor, one can do a search for users created using: sudo lastlog which will show a list of users. I would expect one to exist there that has tor included in it. It might also be found using sudo ls -la /var/run/ which should host the TOR folder, of whose permission would be the one you're looking for to use.
    – ntk4
    Sep 10, 2017 at 2:22
4

I found out that tor was blocked by SElinux. I disabled SElinux and everything was working.

1
  • 1
    You should not disable SElinux, it's a good thing! Do you need help in writing a ruleset for it?
    – Alexey Vesnin
    Mar 16, 2016 at 11:54
0
sudo chown debian-tor:debian-tor /var/lib/tor/site/
sudo systemctl restart tor

fixed it for me.

-1

You're missing DataDirectory /usr/tor/data in your torrc. And make a debian-tor user you've mentioned in your setup have a /bin/bash shell and a home directory /usr/tor - it will solve your problem and help you to run pluggable transports without a problem. Do it like this from root :

mkdir -p /usr/tor/data
chown -R debian-tor:`id -g debian-tor` /usr/tor
usermod -d /usr/tor -s /bin/bash debian-tor
8
  • The DataDirectory should not live under /usr. Furthermore the OP uses a Debian-based system. So there is a high chance that DataDirectory is set correctly.
    – Jens Kubieziel
    Feb 10, 2016 at 17:50
  • I've provided my working example, so it's no problem to set up his own data path, not like /root/.tor of course. And where it should be - tastes different
    – Alexey Vesnin
    Feb 10, 2016 at 17:54
  • The FHS says otherwise.
    – Jens Kubieziel
    Feb 10, 2016 at 23:03
  • @JensKubieziel don't forget, that there's a very handy things at hand in Linux, like AppArmor, privilege separation and CGroups. Take a deep look, and you will understand, that there's nothing bad in residing a whole tor dir inside /usr properly secured
    – Alexey Vesnin
    Feb 10, 2016 at 23:36
  • @AlexeyVesnin Please check out my edit. The hidden service is working with /var/lib/tor/ but not with other directories. Not even /var/lib/tor/hidden_service/
    – Jan Wytze
    Feb 11, 2016 at 14:25

You must log in to answer this question.

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