Skip to main content
May 13, 2022
Question

Generate passwords from op 1P CLI?

  • May 13, 2022
  • 8 replies
  • 1119 views

Is it possible to add command to generate random passwords from the 1P CLI?
Add the https://1password.com/password-generator/ web version also to the "op" command.

Like:
~/home>op --genpass aB! 12
Generates a Password with a length of 12 character with lowercase UPPERCASE and symbols.


1Password Version: Not Provided
Extension Version: Not Provided
OS Version: Not Provided

8 replies

May 16, 2022

Heya!

Thank you for reaching out to us!
Currently, the only way to generate such passwords with the 1Password CLI is with op item create.
Can you please let us know more about your use-case, that would make use of this feature?
For what it's worth, we do have an internal ticket that tracks adding such functionality.
Looking forward to hearing from you!

Best,
Horia

B0rgAuthor
May 19, 2022

@"Horia.Culea_1P" Thank you for your reply.
I just want to create a password not a item in 1P using the CLI. And make a Alfred workflow so the passwords i create are only made by 1P and not pwgen or other password creator sites/tools.

May 19, 2022

Thanks for the follow-up! We'll make sure to update this thread once we have any developments on this front.

Best,
Horia

August 7, 2022

Hi, any updates on this? It would be nice to use a password generator blessed by 1Password.

1Password Employee
August 9, 2022

Hi @gtirloni and thank you for following up on this! As we do not currently support a straight up alternative to pwgen we do provide a (slightly longer but more comprehensive) solution for generating a password AND saving it for future use:

Use the '--generate-password' option to generate and set a random
password for a Login or Password item. By default, it will create a
32-character password made up of letters, numbers, and symbols.

You can customize the password with a password recipe. Specify the
password length and which character types to use in a comma-separated
list. Ingredients are:

  • 'letters' for uppercase and lowercase letters
  • 'digits' for numbers
  • 'symbols' for special characters ('!@.-_*')
  • '1' - '64' for password length

Example for your use case:

op item create --title='retrievable generated password' --category=password --generate-password=20,letters,digits | op read op://Private/'retrievable generated password'/password

This should achieve your desired output and furthermore it will store your password for further retrieval at any later stage using the op read [secret_reference] command.

Hope this helps!

All the best,
Andi

August 9, 2022

Thank you, much appreciated.

1Password Employee
August 9, 2022

Glad I could help!

May 19, 2026

Note that you can use the --dry-run switch in combination with --generate-password and --reveal to generate a password without creating an item and storing it in 1Password e.g.:

op item create --dry-run --generate-password=64,letters,digits,symbols --reveal --category Password
...
Fields:
  password:    RFGaQyiBP_M7kGonw.2mMCC@uYAYYkboHZy-fh9rW-BVTgQy@QawtdQLGC@NcWZV