Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

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

Solved Go to solution

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

New Contributor

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

Accepted Solutions

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

Super 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
5 REPLIES 5

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

Super 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

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

New Contributor

@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.

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

Super 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)

.

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

Super 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.

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

New Contributor

@Jay SenSharma

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

Don't have an account?
Coming from Hortonworks? Activate your account here