Newer Version Available

This content describes an older version of this product. View Latest

Generate or Change a Password for a Scratch Org User

By default, new scratch orgs contain one administrator user with no password. You can optionally set a password when you create a user. Use the CLI to generate or change a password for any scratch org user. After it's set, you can’t unset a password, you can only change it.
  1. 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 username must be an administrator user. The --onbehalfof parameter lets you assign passwords 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:

    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 --length and --complexity parameters. The --complexity parameter 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:
  2. View the generated password and other user details:
  3. Log in to the scratch org with the new password:
    1. 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.my.salesforce.com.
    2. 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.
    3. 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 force:user:display output.

Note