Created on 10-10-2017 09:25 AM - edited 09-16-2022 05:22 AM
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?
Created 10-10-2017 09:35 AM
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
Created 10-10-2017 09:35 AM
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
Created 10-10-2017 10:51 AM
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.
Created 10-10-2017 11:12 AM
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)
Created 10-10-2017 11:29 AM
Created 10-10-2017 01:13 PM