Support Questions

Find answers, ask questions, and share your expertise

How to change the default username for Ambari UI which is admin?

avatar

Hello,

I need to change the default username for Ambari UI which is "admin" through Ambari API.

I found the service to change the default password for the default username (admin/admin) :

curl -i -u $AMBARI_ADMIN_USERID:$AMBARI_ADMIN_PASSWORD -H "X-Requested-By: ambari" -X PUT -d '{"Users": { "user_name": "$USER_NAME", "password": "$USER_NEW_PWD", "old_password": "$USER_OLD_PWD"}}' http://$AMBARI_SERVER:8080/api/v1/users/$USER_NAME

So,could anyone help me to find this service?

1 ACCEPTED SOLUTION

avatar
Master Mentor

@raouia

Your command is correct. It should work without any issue.

I tested the same as following:

Example:

curl -i -u admin:admin -H "X-Requested-By: ambari" -X PUT -d '{"Users": { "user_name": "admin", "password": "admin_new_pwd", "old_password": "admin"}}' http://blueprint.example.com:8080/api/v1/users/admin

.

Here

blueprint.example.com: is my Ambari Server Hostname

admin: is the ambari user name

admin: is old password (If you want to change any other user password then please make sure that you enter admin password only here as this is the password of the admin user. Only Admin user can change password of other users)

admin_new_pwd: is the new admin user password.

Output:

# curl -i -u admin:admin -H "X-Requested-By: ambari" -X PUT -d '{"Users": { "user_name": "admin", "password": "admin_new_pwd", "old_password": "admin"}}' http://blueprint.example.com:8080/api/v1/users/admin
HTTP/1.1 200 OK
X-Frame-Options: DENY
X-XSS-Protection: 1; mode=block
X-Content-Type-Options: nosniff
Cache-Control: no-store
Pragma: no-cache
Set-Cookie: AMBARISESSIONID=1uldktxnl7c1xfgbfx878sows;Path=/;HttpOnly
Expires: Thu, 01 Jan 1970 00:00:00 GMT
User: admin
Content-Type: text/plain
Content-Length: 0

View solution in original post

5 REPLIES 5

avatar
Master Mentor

@raouia

Your command is correct. It should work without any issue.

I tested the same as following:

Example:

curl -i -u admin:admin -H "X-Requested-By: ambari" -X PUT -d '{"Users": { "user_name": "admin", "password": "admin_new_pwd", "old_password": "admin"}}' http://blueprint.example.com:8080/api/v1/users/admin

.

Here

blueprint.example.com: is my Ambari Server Hostname

admin: is the ambari user name

admin: is old password (If you want to change any other user password then please make sure that you enter admin password only here as this is the password of the admin user. Only Admin user can change password of other users)

admin_new_pwd: is the new admin user password.

Output:

# curl -i -u admin:admin -H "X-Requested-By: ambari" -X PUT -d '{"Users": { "user_name": "admin", "password": "admin_new_pwd", "old_password": "admin"}}' http://blueprint.example.com:8080/api/v1/users/admin
HTTP/1.1 200 OK
X-Frame-Options: DENY
X-XSS-Protection: 1; mode=block
X-Content-Type-Options: nosniff
Cache-Control: no-store
Pragma: no-cache
Set-Cookie: AMBARISESSIONID=1uldktxnl7c1xfgbfx878sows;Path=/;HttpOnly
Expires: Thu, 01 Jan 1970 00:00:00 GMT
User: admin
Content-Type: text/plain
Content-Length: 0

avatar

@Jay SenSharma

Thank you for your reply.

My question is how to change the username for Ambari UI which is by default "admin".

I explained that i only found the service to change the default password for admin user and that I'm looking for similar service but this time is to change the default username.

avatar
Master Mentor

@raouia

You can not change the username using Ambari APIs.

The user information is stored inside the ambari Database. This is how you can login to ambari DB

[root@amb25101 ~]# psql -U ambari ambari
Password for user ambari:  bigdata
psql (9.2.18)
Type "help" for help.

ambari=> select user_id, user_name, user_password from users;
 user_id | user_name |                                  user_password                                   
---------+-----------+----------------------------------------------------------------------------------
       1 | admin     | b3ca8cd26130ff701e1fd9ee18f310b2efdf27876b1fb8330367a055cb5852a3c26885a71affdd63
(6 rows)

.

avatar
Master Mentor

@raouia

So you can change the default ambari admin username "admin" directly inside the Ambari Database using the following query.

UPDATE users SET user_name = 'ambariadmin' WHERE user_name='admin';

.

Any changes we make in the ambari Database requires a ambari server restart.

avatar

@Jay SenSharma

Thank you for your pertinent explanation. Now, i found a way to change the default username through the DB.