# org generate password

Generate a random password for scratch org users.

## Description for org generate password

By default, new scratch orgs contain one admin user with no password. Use this 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. This command doesn't work for users you created in the scratch org using Setup.

To change the password strength, set the --complexity flag to a value between 3 and 5. Each value specifies the types of characters used in the generated password:

3 - lower and upper case letters and numbers only

4 - lower and upper case letters and symbols only

5 - lower and upper case letters and numbers and symbols only

To see a password that was previously generated, run "org auth show-user-password".

## Flags

| Flag Name (Long) | Flag Name (Short) | Description                                                                                                                                                       |
| ---------------- | ----------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `--api-version`  | N/A               | **Type:** Value<br><br>Override the api version used for api requests made by this command                                                                        |
| `--complexity`   | `-c`              | **Type:** Value<br>**Default value:** `5`<br><br>Level of password complexity or strength; the higher the value, the stronger the password.                       |
| `--flags-dir`    | N/A               | **Type:** Value<br><br>Import flag values from a directory.                                                                                                       |
| `--json`         | N/A               | **Type:** Boolean<br><br>Format output as json.                                                                                                                   |
| `--length`       | `-l`              | **Type:** Value<br>**Default value:** `20`<br><br>Number of characters in the generated password; valid values are between 20 and 1000. Default value is 20.      |
| `--on-behalf-of` | `-b`              | **Type:** Value<br><br>Comma-separated list of usernames or aliases to assign the password to; must have been created locally with the "org create user" command. |
| `--target-org`   | `-o`              | **Type:** Value<br>**Required**<br><br>Username or alias of the target org. Not required if the `target-org` configuration variable is already set.               |

## Examples for org generate password

Generate a password for the original admin user of your default scratch org:

```shell
sf org generate password
```

Generate a password that contains 25 characters for the original admin user of the scratch org with alias "my-scratch":

```shell
sf org generate password --length 25 --target-org my-scratch
```

Generate a password for your default scratch org admin user that uses lower and upper case letters and numbers only:

```shell
sf org generate password --complexity 3
```

Generate a password for the specified users in the default scratch org; these users must have been created locally with the "org create user" command:

```shell
sf org generate password --on-behalf-of user1@my.org --on-behalf-of user2@my.org --on-behalf-of user3@my.org
```
