Modified 18:54, 23 Feb 2012 by kirk | Page History
Applies to Product: CloudStack 2.2.x, 3.0
If the password for the admin account has been lost and cannot be reset via UI (e.g. there is no other admin-level account to use), it can be changed it via API, or as a last resort by directly updating the database.
Option 1: API – Follow these steps to reset the password via API calls. This is the preferred method to reset the password. This procedure uses the unauthenticated API interface and typically must be performed on the CloudStack server.
Get the id of the user. In CloudStack 2.2.x the default admin account is id 2. In CloudStack 3.0 the id will be a GUID.
curl 'http://localhost:8096/api?command=listUsers&username=admin' 2>/dev/null | xmllint –format – -o -
Using the id from step 1, set a new password. The following sets it to the default of "password" for account id 2.
curl 'http://localhost:8096/api?command=updateUser&id=2&password=5f4dcc3b5aa765d61d8327deb882cf99' 2>/dev/null | xmllint –format – -o –
Option 2: Database – Follow these steps to reset the password directly in the CloudStack database. This procedure must be done on a server that has the MySQL client installed and access to the CloudStack database.
BACK UP THE DATABASE, for example with the following command.
mysqldump -u root -ptherootpassword cloud > cloud_backup.sql
Enter the MySQL CLI.
mysql -u root -ptherootpassword cloud
If desired, run a query to view the existing configuration for the admin account.
SELECT id,username,password FROM user WHERE username = 'admin';
The password will normally be in the form of an MD5 hash. Run a Google search on that hash and if the password was weak (e.g. a dictionary word) there will probably be a result with the plaintext password.
To change the password, set the "password" field to the MD5 hash of the new password. The following sets it to the default of "password":
UPDATE user SET password = '5f4dcc3b5aa765d61d8327deb882cf99' WHERE username = 'admin';