Hello there,
I am trying to configure basic security on my Elasticsearch production but i'm getting error when i try to launch a command from the path /usr/share/Elasticsearch/bin i'm getting this error
./elasticsearch-env: line 88: /etc/default/elasticsearch: Permission denied
here is the "ls -l" :
total 3472
-rwxr-xr-x 1 elasticsearch elasticsearch 2985 Jan 6 23:48 elasticsearch
-rwxr-xr-x 1 elasticsearch elasticsearch 501 Jan 6 23:48 elasticsearch-certgen
-rwxr-xr-x 1 elasticsearch elasticsearch 493 Jan 6 23:48 elasticsearch-certutil
-rwxr-xr-x 1 elasticsearch elasticsearch 996 Jan 6 23:48 elasticsearch-cli
-rwxr-xr-x 1 elasticsearch elasticsearch 443 Jan 6 23:48 elasticsearch-croneval
-rwxr-xr-x 1 elasticsearch elasticsearch 5522 Feb 2 14:14 elasticsearch-env
-rwxr-xr-x 1 elasticsearch elasticsearch 1828 Jan 6 23:48 elasticsearch-env-from-file
-rwxr-xr-x 1 elasticsearch elasticsearch 168 Jan 6 23:48 elasticsearch-geoip
-rwxr-xr-x 1 elasticsearch elasticsearch 184 Jan 6 23:48 elasticsearch-keystore
-rwxr-xr-x 1 elasticsearch elasticsearch 450 Jan 6 23:48 elasticsearch-migrate
-rwxr-xr-x 1 elasticsearch elasticsearch 126 Jan 6 23:48 elasticsearch-node
-rwxr-xr-x 1 elasticsearch elasticsearch 176 Jan 6 23:48 elasticsearch-plugin
-rwxr-xr-x 1 elasticsearch elasticsearch 441 Jan 6 23:48 elasticsearch-saml-metadata
-rwxr-xr-x 1 elasticsearch elasticsearch 439 Jan 6 23:48 elasticsearch-service-tokens
-rwxr-xr-x 1 elasticsearch elasticsearch 448 Jan 6 23:48 elasticsearch-setup-passwords
-rwxr-xr-x 1 elasticsearch elasticsearch 118 Jan 6 23:48 elasticsearch-shard
-rwxr-xr-x 1 elasticsearch elasticsearch 483 Jan 6 23:48 elasticsearch-sql-cli
-rwxr-xr-x 1 elasticsearch elasticsearch 3455027 Jan 6 23:48 elasticsearch-sql-cli-7.16.3.jar
-rwxr-xr-x 1 elasticsearch elasticsearch 436 Jan 6 23:48 elasticsearch-syskeygen
-rwxr-xr-x 1 elasticsearch elasticsearch 436 Jan 6 23:48 elasticsearch-users
-rwxr-xr-x 1 elasticsearch elasticsearch 332 Jan 6 23:48 systemd-entrypoint
-rwxr-xr-x 1 elasticsearch elasticsearch 356 Jan 6 23:48 x-pack-env
-rwxr-xr-x 1 elasticsearch elasticsearch 364 Jan 6 23:48 x-pack-security-env
-rwxr-xr-x 1 elasticsearch elasticsearch 363 Jan 6 23:48 x-pack-watcher-env
Ok the directory /etc/default/elasticsearch is owned by the right user and group
-rw-rw---- 1 elasticsearch elasticsearch 1724 Feb 8 15:47 /etc/default/elasticsearch
then i run this command like you said : sudo chmod +x /usr/share/Elasticsearch/bin/Elasticsearch
then i run the command : sudo /usr/share/elasticsearch/bin/elasticsearch
and i got this error :
OpenJDK 64-Bit Server VM warning: Option UseConcMarkSweepGC was deprecated in version 9.0 and will likely be removed in a future release.
[2022-02-11T14:43:15,503][ERROR][o.e.b.ElasticsearchUncaughtExceptionHandler] [arkoosnode] uncaught exception in thread [main]
org.elasticsearch.bootstrap.StartupException: java.lang.RuntimeException: can not run elasticsearch as root
at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:170) ~[elasticsearch-7.16.3.jar:7.16.3]
at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:157) ~[elasticsearch-7.16.3.jar:7.16.3]
at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:77) ~[elasticsearch-7.16.3.jar:7.16.3]
at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:112) ~[elasticsearch-cli-7.16.3.jar:7.16.3]
at org.elasticsearch.cli.Command.main(Command.java:77) ~[elasticsearch-cli-7.16.3.jar:7.16.3]
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:122) ~[elasticsearch-7.16.3.jar:7.16.3]
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:80) ~[elasticsearch-7.16.3.jar:7.16.3]
Caused by: java.lang.RuntimeException: can not run elasticsearch as root
at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:107) ~[elasticsearch-7.16.3.jar:7.16.3]
at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:183) ~[elasticsearch-7.16.3.jar:7.16.3]
at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:434) ~[elasticsearch-7.16.3.jar:7.16.3]
at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:166) ~[elasticsearch-7.16.3.jar:7.16.3]
... 6 more
uncaught exception in thread [main]
java.lang.RuntimeException: can not run elasticsearch as root
at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:107)
at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:183)
at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:434)
at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:166)
at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:157)
at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:77)
at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:112)
at org.elasticsearch.cli.Command.main(Command.java:77)
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:122)
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:80)
For complete error details, refer to the log at /var/log/elasticsearch/elasticsearch.log
2022-02-11 14:43:15,874409 UTC [3267] INFO Main.cc@111 Parent process died - ML controller exiting
in the log it tells : Caused by: java.lang.RuntimeException: can not run elasticsearch as root
Thanks
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.