Generate or Change a Password for a Scratch Org User
By default, new scratch orgs contain one administrator user with no password. Use the org generate password CLI command to generate or change a password for this admin user. After it’s set, you can’t unset a password, you can only change it.
You can also use the --on-behalf-of flag to generate a password for a scratch org user that you’ve created locally with the org create user command. You can’t use the org generate password command for users that you created in the scratch org with Setup.
-
Generate a password for a scratch org user with this command:
You can run this command for scratch org users only. The command outputs the generated password.
The target org must be the username or alias for the scratch org admin user. Use the
--on-behalf-offlag to assign passwords to multiple users at once, including admin users, or to users who don’t have permissions to do it themselves. Specify multiple locally created users by specifying multiple--on-behalf-offlags. For example, let’s say the my-scratch alias corresponds to the scratch org’s admin user, and you want to generate a password for users with aliasesci-userandqa-user:By default, the command generates a password that’s 13 characters in length; the possible characters include all lower and upper case letters, numbers, and symbols. To change the password strength, use the
--lengthand--complexityflags. The--complexityflag is a number from 0 through 5; the higher the value, the more possible characters are used, which strengthens the password. The default value is 5. See the command-line help for a description of each value. This example shows how to generate a password that’s 20 characters long: -
View the generated password and other user details with the
org display userandorg authcommands: -
Log in to the scratch org with the new password:
-
From the
org display useroutput, copy the value of the Instance URL and paste it into your browser. In our example, the instance URL ishttps://connect-enterprise-1121-dev-ed.scratch.my.salesforce.com. -
If you’ve already opened the scratch org with the
org opencommand, 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 theorg display usercommand. -
Click Log In to Sandbox.
-
If you change a scratch org user’s password using the Salesforce UI, the new password doesn’t show up in the org display user output.