# Change default admin user

**URL:** <https://forum.opensearch.org/t/change-default-admin-user/11530>\
**Category:** OpenSearch\
**Created:** [November 17, 2022, 3:07pm UTC](https://forum.opensearch.org/t/change-default-admin-user/11530 "2022-11-17T15:07:02Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![kksaha](https://avatars.discourse-cdn.com/v4/letter/k/f14d63/32.png) [@kksaha](https://forum.opensearch.org/u/kksaha)\
**Post date:** [November 17, 2022, 3:07pm UTC](https://forum.opensearch.org/t/change-default-admin-user/11530/1 "2022-11-17T15:07:02Z")

</div>

**Versions** (relevant - OpenSearch/Dashboard/Server OS/Browser): 2.2.0

**Describe the issue** :

We are managing securityplugin through ansible and we are not using securityadmin script to making any configuration change. Everything is working as expected. But while changing the default password for admin user, it’s throwing following error.

**Configuration** :

```auto
configs:
  admin:
    hash: !vault |
      $ANSIBLE_VAULT;1.1;AHS286;default
      38323839613263363663333166353930313035626361323838616164303736643639356663386535
      3631336232653261363431336236326463346237613730320a383135303432623862633736396462
      36346330646164643336303431373265623835343763326430376139383831303865636138653661
      3135663535663261330a613037376332306261613630316461646535613532306531356162333864
      33306664346163636365653636636431623861653033346466656433323864646135
    backend_roles:
      - "admin"

```

**Relevant Logs or Screenshots** :

```auto
fatal: [localhost]: FAILED! => { 
November 17th 2022 19:06:42Info
    "changed": false, 
November 17th 2022 19:06:42Info
    "connection": "close", 
November 17th 2022 19:06:42Info
    "content": "{\"status\":\"FORBIDDEN\",\"message\":\"Resource 'admin' is read-only.\"}", 
November 17th 2022 19:06:42Info
    "content_length": "65", 
November 17th 2022 19:06:42Info
    "content_type": "application/json; charset=UTF-8", 
November 17th 2022 19:06:42Info
    "date": "Thu, 17 Nov 2022 13:36:37 GMT", 
November 17th 2022 19:06:42Info
    "elapsed": 0, 
November 17th 2022 19:06:42Info
    "json": { 
November 17th 2022 19:06:42Info
        "message": "Resource 'admin' is read-only.", 
November 17th 2022 19:06:42Info
        "status": "FORBIDDEN" 
November 17th 2022 19:06:42Info
    }, 
November 17th 2022 19:06:42Info
    "redirected": false, 
November 17th 2022 19:06:42Info
    "status": 403, 
November 17th 2022 19:06:42Info
    "strict_transport_security": "max-age=15724800; includeSubDomains", 
November 17th 2022 19:06:42Info
    "url": "https://opensearch.kishorekumar.cloud:443/_plugins/_security/api/internalusers/admin" 
November 17th 2022 19:06:42Info
} 
November 17th 2022 19:06:42Info
MSG: 
November 17th 2022 19:06:42Info
Status code was 403 and not [200]: HTTP Error 403: Forbidden 

```

How can we change it to non-readonly admin user through ansible.

Could anyone please suggest.

Thanks,  
Kishore

---

<div class="post-metadata">

**Author:** ![jasonrojas](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.opensearch.org/jasonrojas/32/4902_2.png) [@jasonrojas](https://forum.opensearch.org/u/jasonrojas)\
**Post date:** [November 17, 2022, 5:10pm UTC](https://forum.opensearch.org/t/change-default-admin-user/11530/2 "2022-11-17T17:10:41Z")

</div>

When modifying the admin password I believe you have to also set:

```auto
  reserved: false
  hidden: false

```

---

<div class="post-metadata">

**Author:** ![kksaha](https://avatars.discourse-cdn.com/v4/letter/k/f14d63/32.png) [@kksaha](https://forum.opensearch.org/u/kksaha)\
**Post date:** [November 21, 2022, 9:24am UTC](https://forum.opensearch.org/t/change-default-admin-user/11530/3 "2022-11-21T09:24:42Z")

</div>

Thanks @jasonrojas for your suggestion. But “reserved” and “hidden” doesn’t work with api. As I mentioned we are maintaining through ansible.

---

<div class="post-metadata">

**Author:** ![albgus](https://avatars.discourse-cdn.com/v4/letter/a/9d8465/32.png) [@albgus](https://forum.opensearch.org/u/albgus)\
**Post date:** [November 23, 2022, 3:43pm UTC](https://forum.opensearch.org/t/change-default-admin-user/11530/4 "2022-11-23T15:43:11Z")

</div>

The OpenSearch developers has taken the active decision to make it hard to change the default admin password in the default configuration.

Yes, it’s broken by design and I dare to say one of the [_worst_] decisions I’ve seen in software development (how to maximize the number of installations with admin:admin as password!..)

However, it is possible to change, just not very straight forward. The docs you’re looking for is here: [Apply changes with the securityadmin script - OpenSearch documentation](https://opensearch.org/docs/latest/security-plugin/configuration/security-admin/) and you’ll need to find the `internal_users.yml` file in your installation (likely you’re using the default files in `/usr/share/opensearch/config/opensearch-security/`) and run the `securityadmin.sh` script to update it.

Beware that `securityadmin.sh` **will destroy the entire user database** , so if you have made any manual changes, created users, etc. it will have to be redone.

---

<div class="post-metadata">

**Author:** ![jasonrojas](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.opensearch.org/jasonrojas/32/4902_2.png) [@jasonrojas](https://forum.opensearch.org/u/jasonrojas)\
**Post date:** [November 29, 2022, 4:45pm UTC](https://forum.opensearch.org/t/change-default-admin-user/11530/5 "2022-11-29T16:45:47Z")

</div>

Additionally - securityadmin.sh does allow flags to backup/export the current databses of users etc so if you do have anything you want to keep you can go that route.

---

<div class="post-metadata">

**Author:** ![kksaha](https://avatars.discourse-cdn.com/v4/letter/k/f14d63/32.png) [@kksaha](https://forum.opensearch.org/u/kksaha)\
**Post date:** [December 6, 2022, 3:00pm UTC](https://forum.opensearch.org/t/change-default-admin-user/11530/6 "2022-12-06T15:00:46Z")

</div>

Thanks @jasonrojas@albgus for your input.

I just copied internal\_users.yaml file with “reserved: false” (for Admin user) on /tmp folder and ran the security script to disable read-only access. And then it’s allow me to change default admin password.

---

<div class="post-metadata">

**Author:** ![kksaha](https://avatars.discourse-cdn.com/v4/letter/k/f14d63/32.png) [@kksaha](https://forum.opensearch.org/u/kksaha)\
**Post date:** [December 6, 2022, 3:02pm UTC](https://forum.opensearch.org/t/change-default-admin-user/11530/7 "2022-12-06T15:02:24Z")

</div>

BTW is there any mechanism that we can apply to change the admin password periodically like in every month without any manual intervention. Please suggest.

---

<div class="post-metadata">

**Author:** ![Ashutosh](https://avatars.discourse-cdn.com/v4/letter/a/e480ec/32.png) [@Ashutosh](https://forum.opensearch.org/u/Ashutosh)\
**Post date:** [August 5, 2023, 4:47am UTC](https://forum.opensearch.org/t/change-default-admin-user/11530/8 "2023-08-05T04:47:42Z")

</div>

@kksaha @jasonrojas

I am using OpenSearch helm chart to install OpenSearch and also modified values.yaml file to change admin password for OpenSearch and OpenSearch dashboard but still its now working .  
Could you please guide me to fix this issue .

```auto
  enabled: true
  path: "/usr/share/opensearch/config/opensearch-security"
  actionGroupsSecret:
  configSecret:
  internalUsersSecret:
  rolesSecret:
  rolesMappingSecret:
  tenantsSecret:
  # The following option simplifies securityConfig by using a single secret and
  # specifying the config files as keys in the secret instead of creating
  # different secrets for for each config file.
  # Note that this is an alternative to the individual secret configuration
  # above and shouldn't be used if the above secrets are used.
  config:
    # There are multiple ways to define the configuration here:
    # * If you define anything under data, the chart will automatically create
    # a secret and mount it. This is best option to choose if you want to override all the
    # existing yml files at once.
    # * If you define securityConfigSecret, the chart will assume this secret is
    # created externally and mount it. This is best option to choose if your intention is to
    # only update a single yml file.
    # * It is an error to define both data and securityConfigSecret.
    securityConfigSecret: ""
    dataComplete: true
    data: 
      internal_users.yml: |-
        _meta:
          type: "internalusers"
          config_version: 2
          
        admin:
          hash: "$2y$12$XDdc42zlZ.DhOj44X5zT.OnSxjGj5v7MEUllUG1euFG3wDp/AUGy2"
          reserved: false
          backend_roles:
          - "admin"
          description: "Demo admin user"

        kibanaserver:
          hash: "$2y$12$XDdc42zlZ.DhOj44X5zT.OnSxjGj5v7MEUllUG1euFG3wDp/AUGy2"
          reserved: false
          description: "Demo OpenSearch Dashboards user"

```

Also I tried to do from dashboard and getting this error "failed to reset password . forbidden Resource admin is read-only”  
I even tried to update internal\_user.yml admin hash and then ran securityadmin.sh also . Here is the command “sh securityadmin.sh -cd …/securityconfig/ -icl -nhnv -cacert /etc/elasticsearch/root-ca.pem -cert /etc/elasticsearch/kirk.pem -key /etc/elasticsearch/kirk-key.pem” still no success yet  
\*\*Please suggest what to do to make it working \*\*  
A big thanks in Advance!!

---

<div class="post-metadata">

**Author:** ![kksaha](https://avatars.discourse-cdn.com/v4/letter/k/f14d63/32.png) [@kksaha](https://forum.opensearch.org/u/kksaha)\
**Post date:** [August 7, 2023, 8:22am UTC](https://forum.opensearch.org/t/change-default-admin-user/11530/9 "2023-08-07T08:22:40Z")

</div>

@Ashutosh You can try the following approach if the above-mentioned one doesn’t work.

> [@How to Default Password Reset](https://forum.opensearch.org/t/how-to-default-password-reset/5523):
>
> I tried to change the password in three ways, but all failed. First attempt Viewed the [document](https://opendistro.github.io/for-elasticsearch-docs/docs/security/configuration/yaml/#internal_usersyml) and changed the administrator password. An error occurred when I saw the article [Apply configuration changes using securityadmin.sh](https://opendistro.github.io/for-elasticsearch-docs/docs/security/configuration/security-admin/) ERR: An unexpected IllegalStateException occured: failed to load plugin class [com.amazon.opendistroforelasticsearch.security.OpenDistroSecurityPlugin] Trace: java.lang.IllegalStateException: failed to load plugin class [com.amazon.opendistroforelasticsearch.security.O…
