If you want/need to add password authentication to your FreeBSD Elasticsearch cluster (this should work on any FreeBSD with elasticsearch7)

TLDR; (again)

Add the following lines to your /usr/local/etc/elasticsearch/elasticsearch.yml:

xpack.security.enabled: true
xpack.security.transport.ssl.enabled: true

and restart elasticsearch.

service elasticsearch restart

Make sure curl is installed:

pkg install curl

Link the installed Java into the bundled directory (this is neither recommended nor supported but it does the trick)

mkdir -p /usr/local/lib/elasticsearch/jdk/bin
ln -s /usr/local/bin/java /usr/local/lib/elasticsearch/jdk/bin/java

And run the password setup utility (this might take up to 2 minutes)

/usr/local/lib/elasticsearch/bin/elasticsearch-setup-passwords interactive
Do you want to continue with the password setup process [y/N]
y

Initiating the setup of passwords for reserved users elastic,apm\_system,kibana,kibana\_system,logstash\_system,beats\_system,remote\_monitoring\_user.
You will be prompted to enter passwords as the process progresses.
Please confirm that you would like to continue [y/N]
y

Enter password for [elastic]:
Reenter password for [elastic]:
Enter password for [apm_system]:
Reenter password for [apm_system]:
Enter password for [kibana_system]:
Reenter password for [kibana_system]:
Enter password for [logstash_system]:
Reenter password for [logstash_system]:
Enter password for [beats_system]:
Reenter password for [beats_system]:
Enter password for [remote\_monitoring\_user]:
Reenter password for [remote\_monitoring\_user]:
Changed password for user [apm_system]
Changed password for user [kibana_system]
Changed password for user [kibana]
Changed password for user [logstash_system]
Changed password for user [beats_system]
Changed password for user [remote\_monitoring\_user]
Changed password for user [elastic]

Yes, it’s just a symlink.