Starting a service as a different user

Support for security such as Firewalls and securing linux
Post Reply
jordend
Posts: 3
Joined: 2015/11/04 16:18:49

Starting a service as a different user

Post by jordend » 2015/11/04 16:22:01

Hi,

I have my CentOS box running a backup server and I want it to automatically run two services at startup as a specific user. Any help with this would be greatly appreciated. Thanks!

aks
Posts: 3073
Joined: 2014/09/20 11:22:14

Re: Starting a service as a different user

Post by aks » 2015/11/04 17:44:57

Depends on the program(s) involved. You should really look at using systemd, but that too depends on the programs and how they behave.

From the shell (so a script too), you could use su <user> -c "<commands_to_run> > <log_file> 2>&1 " &

jordend
Posts: 3
Joined: 2015/11/04 16:18:49

Re: Starting a service as a different user

Post by jordend » 2015/11/04 17:46:35

Where would I put that script for it to start that service at startup?

User avatar
TrevorH
Site Admin
Posts: 33202
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Starting a service as a different user

Post by TrevorH » 2015/11/04 18:04:55

Systemd unit files should go in /etc/systemd/system and you can look in /usr/lib/systemd/system for examples of others that are already in use to find one similar to the things you want to do. I believe the correct thing to put in the unit file would be User=youruser
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

jordend
Posts: 3
Joined: 2015/11/04 16:18:49

Re: Starting a service as a different user

Post by jordend » 2015/11/04 21:50:47

Well, after all that, I found out from the vendor that this has to be ran as root. :/

aks
Posts: 3073
Joined: 2014/09/20 11:22:14

Re: Starting a service as a different user

Post by aks » 2015/11/05 18:52:36

That's not good :twisted:
Complain and tell them your giving them money for what amounts to the crappiest of crap....

Post Reply