Newer Version Available
Generate or Change a Password for a Scratch Org User
-
Generate a password for a scratch org user with this command:
1sfdx force:user:password:generate --targetusername <username>You can run this command for scratch org users only. The command outputs the generated password.
The target username must be an administrator user. The --onbehalfof parameter lets you assign permsets to multiple users at once, including admin users, or to users who don’t have permissions to do it themselves. Specify multiple users by separating them with commas; enclose them in quotes if you include spaces. The command still requires an administrator user which you specify with the --targetusername parameter. For example, let’s say the administrator user has alias admin-user and you want to generate a password for users with aliases ci-user and qa-user:
1sfdx force:user:password:generate --targetusername admin-user --onbehalfof ci-user,qa-user -
View the generated password and other user details:
1sfdx force:user:display --targetusername ci-user 2 3=== User Description 4KEY VALUE 5─────────────── ─────────────────────────────────────────────────────────── 6Access Token <long-string> 7Alias ci-user 8Id 005xx000001SvBaAAK 9Instance Url https://innovation-ability-4888-dev-ed.cs46.my.salesforce.com 10Login Url https://innovation-ability-4888-dev-ed.cs46.my.salesforce.com 11Org Id 00D9A0000000SXKUA2 12Profile Name Standard User 13Username 1505774874884_test-sug5dr2vzoj1@your_company.net -
Log in to the scratch org with the new password:
- From the force:user:display output, copy the value of Instance URL and paste it into your browser. In our example, the instance URL is https://site-fun-3277.cs46.my.salesforce.com.
- If you’ve already opened the scratch org with the force:org:open command, you’re automatically logged in again. To try out the new password, log out and enter the username and password listed in the output of the force:user:display command.
- Click Log In to Sandbox.