Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs say elasticsearch-keystore must be run as the elasticsearch user but that fails because of permissions #66133

Closed
jamshid opened this issue Dec 9, 2020 · 3 comments
Labels
>bug :Delivery/Packaging RPM and deb packaging, tar and zip archives, shell and batch scripts >docs General docs changes Team:Delivery Meta label for Delivery team Team:Docs Meta label for docs team

Comments

@jamshid
Copy link

jamshid commented Dec 9, 2020

Elasticsearch version (bin/elasticsearch --version):

 /usr/share/elasticsearch/bin/elasticsearch --version
OpenJDK 64-Bit Server VM warning: Option UseConcMarkSweepGC was deprecated in version 9.0 and will likely be removed in a future release.
Version: 7.5.2, Build: default/rpm/8bec50e1e0ad29dad5653712cf3bb580cd1afcdf/2020-01-15T12:11:52.313576Z, JVM: 13.0.1

Plugins installed: []

# /usr/share/elasticsearch/bin/elasticsearch-plugin list
prometheus-exporter

JVM version (java -version):

# /usr/share/elasticsearch/jdk/bin/java -version
openjdk version "13.0.1" 2019-10-15

OS version (uname -a if on a Unix-like system):

Linux 5003b6fd18ce 5.4.39-linuxkit #1 SMP Fri May 8 23:03:06 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

Description of the problem including expected versus actual behavior:

The default install permissions on /etc/elasticsearch is that it's owned by root:elasticsearch but group elasticsearch cannot add files.

drwxr-s--- 1 root elasticsearch  4096 Dec  8 23:23 .
-rw-rw---- 1 root elasticsearch   160 Dec  8 23:23 elasticsearch.keystore

It's mentioned in issues like #44624 the keystore is created if it does not exist:

If the keystore does not exist, we auto create it. This is because we always need the keystore.seed value, and do not want archive users to need additional setup before running Elasticsearch.

But the elasticsearch service cannot auto create it because of directory permissions -- journalctl -u elasticsearch will show

Dec 08 23:23:46 0786d81661fb elasticsearch[757]: Exception in thread "main" org.elasticsearch.bootstrap.BootstrapException: org.elasticsearch.cli.UserException: un
Dec 08 23:23:46 0786d81661fb elasticsearch[757]: Likely root cause: java.nio.file.AccessDeniedException: /etc/elasticsearch/elasticsearch.keystore.tmp

Seems the only way this works is to make elasticsearch the owner of /etc/elasticsearch, but that is not documented.

Steps to reproduce:

I don't understand why docs say to only run elasticsearch-keystore as the elasticsearch user
https://www.elastic.co/guide/en/elasticsearch/reference/current/elasticsearch-keystore.html

Important: This command should be run as the user that will run Elasticsearch.

when that does not work:

[root@d889d59d4b36 /]# su -s /bin/bash elasticsearch   
bash-4.2$ /usr/share/elasticsearch/bin/elasticsearch-keystore list
keystore.seed
bash-4.2$ /usr/share/elasticsearch/bin/elasticsearch-keystore add test1
Enter value for test1: 
ERROR: unable to create temporary keystore at [/etc/elasticsearch/elasticsearch.keystore.tmp], write permissions required for [/etc/elasticsearch] or run [elasticsearch-keystore upgrade]

(elasticsearch-keystore upgrade did not report an error but it didn't help)

Provide logs (if relevant):

example provided above

This seems related to:
#26309
#64207

@jamshid jamshid added >bug needs:triage Requires assignment of a team area label labels Dec 9, 2020
@tvernum tvernum added :Delivery/Packaging RPM and deb packaging, tar and zip archives, shell and batch scripts and removed needs:triage Requires assignment of a team area label labels Dec 14, 2020
@elasticmachine elasticmachine added the Team:Delivery Meta label for Delivery team label Dec 14, 2020
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-delivery (Team:Delivery)

@pugnascotia pugnascotia added the >docs General docs changes label Jun 20, 2022
@elasticmachine elasticmachine added the Team:Docs Meta label for docs team label Jun 20, 2022
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-docs (Team:Docs)

@mark-vieira
Copy link
Contributor

This issue is missing some details such as the Elasticsearch version and packaging type. I assume this is a deb or rpm package since those use /etc/elasticsearch for configuration but we always create a keystore on installation so I don't think this is an issue anymore. I'm going to close this issue for now since I think it's overcome by events.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>bug :Delivery/Packaging RPM and deb packaging, tar and zip archives, shell and batch scripts >docs General docs changes Team:Delivery Meta label for Delivery team Team:Docs Meta label for docs team
Projects
None yet
Development

No branches or pull requests

5 participants