This guide is for anyone getting an OpenSearch cluster ready for production. OpenSearch is an open-source search and analytics engine, and its Security plugin checks who is calling and what they are allowed to do on every request. The plugin comes switched on, but with self-signed demo certificates (certificates anyone can copy from the public download) that are not safe to keep. Here you will replace that demo setup step by step. You will create internal users, define roles and link users to them (this is RBAC, or role-based access control), and install real TLS certificates. TLS (Transport Layer Security) is the encryption that protects traffic between clients and nodes. You will also turn on audit logging, which records who did what, and push each change to the cluster with the securityadmin.sh tool.
How to verify
After config, confirm the security plugin is enforcing access:
curl -sk https://os:9200/ # 401 expected
curl -sk -u admin:"$PW" https://os:9200/_plugins/_security/api/account?pretty
curl -sk -u admin:"$PW" https://os:9200/_plugins/_security/api/roles?pretty | jq 'keys[]'
curl -sk -u admin:"$PW" https://os:9200/_plugins/_security/authinfo?pretty
curl -sk -u admin:"$PW" https://os:9200/_plugins/_security/api/internalusers?pretty | jq 'keys[]'
Healthy: unauthenticated requests get 401, authenticated requests return user/role info, audit logs are landing in audit-* indices.
What’s happening
The Security plugin owns five things:
- Authentication — internal user database (bcrypt hashed), HTTP basic, JWT, LDAP, Active Directory, SAML, OIDC, client certificate auth.
- Authorization — roles define cluster and index permissions; role mappings link users/groups/backend roles to roles.
- TLS — separate certificates for transport (node-to-node) and HTTP (client-facing). Mutual TLS on transport is mandatory.
- Audit logging — every event (auth success/failure, index access, config change) can be logged to an
audit-*index. - Tenants — multi-tenant separation of saved objects in OpenSearch Dashboards.
All configuration lives in YAML files under /etc/opensearch/opensearch-security/ and is loaded into the .opendistro_security index via securityadmin.sh. Direct API edits are also possible (/_plugins/_security/api/*), but the YAML + securityadmin pattern is the recommended source of truth.
The plugin starts with demo certificates and an admin/admin user — replace both before exposing the cluster to anything other than localhost.
The procedure
1. Generate real TLS material. Create a private CA, then per-node certificates:
mkdir -p /etc/opensearch/certs && cd /etc/opensearch/certs
openssl genrsa -out root-ca-key.pem 2048
openssl req -new -x509 -sha256 -key root-ca-key.pem -days 3650 \
-subj "/C=CA/O=StackHarbor/CN=OpenSearch Root CA" \
-out root-ca.pem
# Admin cert (used by securityadmin.sh)
openssl genrsa -out admin-key.pem 2048
openssl req -new -key admin-key.pem -subj "/CN=admin" -out admin.csr
openssl x509 -req -in admin.csr -CA root-ca.pem -CAkey root-ca-key.pem -CAcreateserial \
-days 365 -out admin.pem
# Node cert (repeat per node, set CN to the hostname)
openssl genrsa -out node1-key.pem 2048
openssl req -new -key node1-key.pem \
-subj "/CN=os-node1.internal" -out node1.csr
openssl x509 -req -in node1.csr -CA root-ca.pem -CAkey root-ca-key.pem -CAcreateserial \
-days 365 -out node1.pem -extfile <(printf "subjectAltName=DNS:os-node1.internal,IP:10.0.0.10")
2. Configure /etc/opensearch/opensearch.yml to use the real certs:
plugins.security.ssl.transport.pemcert_filepath: certs/node1.pem
plugins.security.ssl.transport.pemkey_filepath: certs/node1-key.pem
plugins.security.ssl.transport.pemtrustedcas_filepath: certs/root-ca.pem
plugins.security.ssl.transport.enforce_hostname_verification: true
plugins.security.ssl.http.enabled: true
plugins.security.ssl.http.pemcert_filepath: certs/node1.pem
plugins.security.ssl.http.pemkey_filepath: certs/node1-key.pem
plugins.security.ssl.http.pemtrustedcas_filepath: certs/root-ca.pem
plugins.security.allow_default_init_securityindex: true
plugins.security.authcz.admin_dn:
- "CN=admin"
plugins.security.audit.type: internal_opensearch
plugins.security.enable_snapshot_restore_privilege: true
3. Rotate the admin user password. Edit /etc/opensearch/opensearch-security/internal_users.yml:
admin:
hash: "$2y$12$..." # bcrypt hash, generated below
reserved: true
backend_roles:
- "admin"
description: "Admin user"
logstash_writer:
hash: "$2y$12$..."
backend_roles:
- "logstash"
readonly_observability:
hash: "$2y$12$..."
backend_roles:
- "observability_read"
Generate bcrypt hashes:
/usr/share/opensearch/plugins/opensearch-security/tools/hash.sh -p 'NewAdminPassw0rd!'
4. Author roles and role mappings. Edit roles.yml:
logstash_writer:
cluster_permissions:
- cluster_monitor
- cluster_composite_ops
- indices:admin/template/get
- indices:admin/template/put
index_permissions:
- index_patterns:
- "logs-*"
allowed_actions:
- "crud"
- "create_index"
observability_read:
cluster_permissions:
- cluster_monitor
index_permissions:
- index_patterns:
- "logs-*"
- "metrics-*"
allowed_actions:
- "read"
- "search"
Edit roles_mapping.yml:
logstash_writer:
backend_roles:
- "logstash"
observability_read:
backend_roles:
- "observability_read"
users:
- "alice@example.com"
5. Sync config to the security index via securityadmin.sh:
/usr/share/opensearch/plugins/opensearch-security/tools/securityadmin.sh \
-cd /etc/opensearch/opensearch-security \
-icl -nhnv \
-cacert /etc/opensearch/certs/root-ca.pem \
-cert /etc/opensearch/certs/admin.pem \
-key /etc/opensearch/certs/admin-key.pem
The plugin reloads in-place; no restart needed. Run this on any node.
6. Enable audit logging. Edit audit.yml:
config:
audit:
ignore_users: []
enable_rest: true
disabled_rest_categories: [AUTHENTICATED]
enable_transport: true
disabled_transport_categories: [GRANTED_PRIVILEGES, AUTHENTICATED]
resolve_bulk_requests: true
log_request_body: false
resolve_indices: true
Re-run securityadmin.sh to push. Audit events land in audit-YYYY.MM.dd indices; apply ISM retention so they don’t grow unbounded.
Operational notes
- Never run
securityadmin.sh -i .opendistro_securityfrom a fresh state without backups — it overwrites the security config index. enforce_hostname_verification: trueon transport prevents a stolen cert from being used on a wrong-named node. Worth the strictness.- Backend roles vs roles. Backend roles come from the auth backend (LDAP groups, JWT claims). Roles are defined inside OpenSearch. Map one to the other via
roles_mapping.yml. - Field-level and document-level security add a per-query filter applied transparently. Performance cost is real on high-cardinality fields; profile before enabling broadly.
- Tenants are an OpenSearch Dashboards concept. They don’t apply to direct API access — they namespace saved objects, not data. See OpenSearch Dashboards vs Kibana for the broader UI context.
- Multi-cluster JWT propagation uses the
JWTHTTP authenticator with a shared signing key. Useful for federation but requires careful key management.
In the engagements we run, the Security plugin is non-negotiable in production. The demo certs and admin/admin credentials are a footgun — they ship enabled and stay that way until someone notices the cluster is open. Hardening is a checklist: real certs, named users with bcrypt, role-mapped to backend identities, audit log retained, snapshots of the security index. See /en/services/managed-operations/ for how we operate hardened OpenSearch clusters.