-
Notifications
You must be signed in to change notification settings - Fork 97
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
wazuh-passwords-tool.sh fails with specific /etc/wazuh-indexer/opensearch.yml configuration #1958
Comments
Update ReportReproducing the errorWith the following content (snippet) of the #network.host: "X.X.X.X"
network.host: "127.0.0.1"
node.name: "node-1"
cluster.initial_master_nodes:
- "node-1"
cluster.name: "wazuh-cluster" The error is reproduced: The IP variable fetches the commented lineroot@ubuntu22:/home/vagrant# bash wazuh-passwords-tool.sh -a
26/10/2023 10:23:49 INFO: Wazuh API admin credentials not provided, Wazuh API passwords not changed.
++ grep -hr network.host: /etc/wazuh-indexer/opensearch.yml
+ IP='#network.host: "X.X.X.X"
network.host: "127.0.0.1"'
+ NH='network.host: '
+ IP='#"X.X.X.X"
"127.0.0.1"'
+ [[ #"X.X.X.X"
"127.0.0.1" =~ _.*_ ]]
+ '[' '#"X.X.X.X"
"127.0.0.1"' == 0.0.0.0 ']'
+ set +x
**************************************************************************
** This tool will be deprecated in the next major release of OpenSearch **
** https://github.com/opensearch-project/security/issues/1755 **
**************************************************************************
Security Admin v7
ERR: Parsing failed. Reason: Missing argument for option: h
usage: securityadmin.sh [-arc] [-backup <folder>] [-cacert <file>] [-cd
<directory>] [-cert <file>] [-cn <clustername>] [-dci] [-dg] [-dra]
[-ec <cipers>] [-ep <protocols>] [-er <number of replicas>] [-era]
[-esa] [-f <file>] [-ff] [-h <host>] [-i <indexname>] [-icl] [-key
<file>] [-keypass <password>] [-ks <file>] [-ksalias <alias>]
[-kspass <password>] [-kst <type>] [-migrate <folder>] [-mo
<folder>] [-nhnv] [-p <port>] [-prompt] [-r] [-rev] [-rl] [-si]
[-sniff] [-t <file-type>] [-ts <file>] [-tspass <password>] [-tst
<type>] [-us <number of replicas>] [-vc <version>] [-w]
-arc,--accept-red-cluster Also operate on a red
cluster. If not specified
the cluster state has to
be at least yellow.
-backup <folder> Backup configuration to
folder
-cacert <file> Path to trusted cacert
(PEM format)
-cd,--configdir <directory> Directory for config files
-cert <file> Path to admin certificate
in PEM format
-cn,--clustername <clustername> Clustername (do not use
together with -icl)
-dci,--delete-config-index Delete
'.opendistro_security'
config index and exit.
-dg,--diagnose Log diagnostic trace into
a file
-dra,--disable-replica-autoexpand Disable replica auto
expand and exit
-ec,--enabled-ciphers <cipers> Comma separated list of
enabled TLS ciphers
-ep,--enabled-protocols <protocols> Comma separated list of
enabled TLS protocols
-er,--explicit-replicas <number of replicas> Set explicit number of
replicas or autoexpand
expression for
.opendistro_security index
-era,--enable-replica-autoexpand Enable replica auto expand
and exit
-esa,--enable-shard-allocation Enable all shard
allocation and exit.
-f,--file <file> file
-ff,--fail-fast fail-fast if something
goes wrong
-h,--hostname <host> OpenSearch host (default:
localhost)
-i,--index <indexname> The index OpenSearch
Security uses to store the
configuration
-icl,--ignore-clustername Ignore clustername (do not
use together with -cn)
-key <file> Path to the key of admin
certificate
-keypass <password> Password of the key of
admin certificate
(optional)
-ks,--keystore <file> Path to keystore
(JKS/PKCS12 format
-ksalias,--keystore-alias <alias> Keystore alias
-kspass,--keystore-password <password> Keystore password
-kst,--keystore-type <type> JKS or PKCS12, if not
given we use the file
extension to dectect the
type
-migrate <folder> Migrate and use folder to
store migrated files
-mo,--migrate-offline <folder> Migrate and use folder to
store migrated files
-nhnv,--disable-host-name-verification Disable hostname
verification
-p,--port <port> OpenSearch transport port
(default: 9200)
-prompt,--prompt-for-password Prompt for password if not
supplied
-r,--retrieve retrieve current config
-rev,--resolve-env-vars Resolve/Substitute env
vars in config with their
value before uploading
-rl,--reload Reload the configuration
on all nodes, flush all
Security caches and exit
-si,--show-info Show system and license
info
-sniff,--enable-sniffing Enable
client.transport.sniff
-t,--type <file-type> file-type
-ts,--truststore <file> Path to truststore
(JKS/PKCS12 format)
-tspass,--truststore-password <password> Truststore password
-tst,--truststore-type <type> JKS or PKCS12, if not
given we use the file
extension to dectect the
type
-us,--update_settings <number of replicas> Update the number of
Security index replicas,
reload configuration on
all nodes and exit
-vc,--validate-configs <version> Validate config for
version 6 or 7 (default 7)
-w,--whoami Show information about the
used admin certificate
26/10/2023 10:23:55 ERROR: The backup could not be created
Fixing the problemThe line that perform this operation is the following: By addint the 🟢 With this change, the passwords are correctly changed, and no errors are generated: root@ubuntu22:/home/vagrant# bash wazuh-passwords-tool.sh -a
26/10/2023 10:26:00 INFO: Wazuh API admin credentials not provided, Wazuh API passwords not changed.
++ grep -hr '^network.host:' /etc/wazuh-indexer/opensearch.yml
+ IP='network.host: "127.0.0.1"'
+ NH='network.host: '
+ IP='"127.0.0.1"'
+ [[ "127.0.0.1" =~ _.*_ ]]
+ '[' '"127.0.0.1"' == 0.0.0.0 ']'
+ set +x
26/10/2023 10:26:18 INFO: The password for user admin is 1ZCfgE5oxmdR*aIP+BBMg1*jN?UfMd?1
26/10/2023 10:26:18 INFO: The password for user kibanaserver is s03CvlCfz5Z+LL5zg3l7J8xVjkXjYV8O
26/10/2023 10:26:18 INFO: The password for user kibanaro is zuZkPzc7LwCbSzRemGKNe+9eSrgbL8a5
26/10/2023 10:26:18 INFO: The password for user logstash is nnr9G*nFD*G0CwW?keUyL9LO7tM2fsFK
26/10/2023 10:26:18 INFO: The password for user readall is 5TvTfGZDJVTVFVhvPfa*C*sM6pyS2uLk
26/10/2023 10:26:18 INFO: The password for user snapshotrestore is hsNr8+lBK+a7YzK0.hJpdUn2hicdz.9a
26/10/2023 10:26:18 WARNING: Wazuh indexer passwords changed. Remember to update the password in the Wazuh dashboard and Filebeat nodes if necessary, and restart the services.
root@ubuntu22:/home/vagrant# |
When running
wazuh-passwords-tool.sh
with the followingopensearch.yml
config:The script fails with the following error:
After checking out the script, the function
passwords_getNetworkHost
seems to incorrectly return both the commented-out line and the one below that, providing following functions with an extra, unexpected parameter.This could be fixed by having the comment as the second line, but maybe it should be investigated and possibly fixed.
The text was updated successfully, but these errors were encountered: