# Kibana start as a service using another user other than root

**URL:** <https://discuss.elastic.co/t/kibana-start-as-a-service-using-another-user-other-than-root/189637>\
**Category:** Kibana\
**Created:** [July 9, 2019, 11:20pm UTC](https://discuss.elastic.co/t/kibana-start-as-a-service-using-another-user-other-than-root/189637 "2019-07-09T23:20:09Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![vikasp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vikasp/32/90872_2.png) [@vikasp](https://discuss.elastic.co/u/vikasp)\
**Post date:** [July 9, 2019, 11:20pm UTC](https://discuss.elastic.co/t/kibana-start-as-a-service-using-another-user-other-than-root/189637/1 "2019-07-09T23:20:09Z")

</div>

Hi,  
I have kibana 5.4.2 installed on a server. I can start the service with no problem when I am logged as a root user using "systemctl start kibana" or "service kibana start".

I have the kibana.service file at /etc/systemd/system/kibana.service as below:

[Unit]  
Description=Kibana

[Service]  
Type=simple  
User=svc\_tst\_elk  
Group=gp\_svc\_tst\_elk  
# Load env vars from /etc/default/ and /etc/sysconfig/ if they exist.  
# Prefixing the path with '-' makes it try to load, but if the file doesn't  
# exist, it continues onward.  
EnvironmentFile=-/etc/default/kibana  
#EnvironmentFile=-/etc/sysconfig/kibana  
ExecStart=/usr/share/kibana/bin/kibana "-c /etc/kibana/kibana.yml"  
Restart=always  
WorkingDirectory=/

[Install]  
WantedBy=multi-user.target

and the env as /etc/default/kibana:

user="svc\_tst\_elk"  
group="gp\_svc\_tst\_elk"  
chroot="/"  
chdir="/"  
nice=""

# If this is set to 1, then when `stop` is called, if the process has  
# not exited within a reasonable time, SIGKILL will be sent next.  
# The default behavior is to simply log a message "program stop failed; still running"  
KILL\_ON\_STOP\_TIMEOUT=0

When, I try to start the kibana service with the user svc\_tst\_elk:  
I see this entry in the kibana.stderr:  
chroot: cannot change root directory to /: Operation not permitted

Also, the user svc\_tst\_elk is/has permissions to run the commands /sbin/service kibana start/stop.

---

<div class="post-metadata">

**Author:** ![Aaron\_Caldwell](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aaron_caldwell/32/45755_2.png) [@Aaron\_Caldwell](https://discuss.elastic.co/u/Aaron_Caldwell)\
**Post date:** [July 10, 2019, 12:11am UTC](https://discuss.elastic.co/t/kibana-start-as-a-service-using-another-user-other-than-root/189637/2 "2019-07-10T00:11:50Z")

</div>

Hello Vikas,

I wonder if your problem is similar to the problem(s) described in [this issue](https://github.com/elastic/kibana/issues/6730). Looks like there were a few solutions tried there, maybe one of them might work well for you?

Regards,  
Aaron

---

<div class="post-metadata">

**Author:** ![vikasp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vikasp/32/90872_2.png) [@vikasp](https://discuss.elastic.co/u/vikasp)\
**Post date:** [July 10, 2019, 5:02pm UTC](https://discuss.elastic.co/t/kibana-start-as-a-service-using-another-user-other-than-root/189637/3 "2019-07-10T17:02:28Z")

</div>

Hi Aaron,  
Thanks for the link, but it doesn't look that way.  
I have all the folders below already owned by the svc\_tst\_elk user.  
/usr/share/kibana (bin directory and the executables)  
/var/log/kibana (stdout and stderr)  
/etc/kibana (configs)  
/etc/systemd/system/kibana.service  
/etc/default/kibana

the error says,  
when I try to start with the user other than root:  
chroot: cannot change root directory to /: Operation not permitted.

Can somebody help me understand do we need chroot to /, if so why and  
anyway to resolve this.

Thanks,

---

<div class="post-metadata">

**Author:** ![vikasp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vikasp/32/90872_2.png) [@vikasp](https://discuss.elastic.co/u/vikasp)\
**Post date:** [July 23, 2019, 11:03pm UTC](https://discuss.elastic.co/t/kibana-start-as-a-service-using-another-user-other-than-root/189637/4 "2019-07-23T23:03:42Z")

</div>

Hi,  
So, I updated the user and group to my svc user in one of the file /etc/systemd/system/kibana.service.

But, I found out that the user and group is mentioned in the env file as well and I guess because the env file is defined later in the service file, the user/group mentioned in the env file might have taken precedence.

I updated in both the places and got my issue resolved.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [August 20, 2019, 11:03pm UTC](https://discuss.elastic.co/t/kibana-start-as-a-service-using-another-user-other-than-root/189637/5 "2019-08-20T23:03:43Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
