Looking for a way to publish passwords via script

edited September 28 in CLI

I have a script which generates passwords for devices, and I'm looking for a way to push them into our secure vault on 1password.com. From what I can tell, there is no API to do this, and the CLI mechanism doesn't seem to be appropriate to call from a script (interactively prompts for user's master password)

I there a way to do this, or alternatively, have 1password generate and provide me the password to use in setting the password on the device?

Thanks


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

Comments

  • Matthew_1PMatthew_1P

    Team Member

    Hey @xReD-BaRoNx, I hope my answers below help out a little!

    have 1password generate and provide me the password to use in setting the password on the device?

    1Password can generate passwords using the following command:

    $ op create item Login [username=<username>] --generate-password [--title=<title>] [--vault=<vault>]
    {"uuid":"...","createdAt":"...","updatedAt":"...","vaultUuid":"..."}
    

    You can therefore combine this with op get item to fetch the new password. Using bash and jq to create a new item and fetch the generated password, you'd do something like this:

    $ op create item Login [username=<username>] --generate-password [--title=<title>] [--vault=<vault>] | jq '.uuid' | op get item - --fields password
    bYjLUjGrs-VKIMCOXRk-IrvqgL__6UmN
    

    If you're using a script, then you just need to parse the JSON returned by op create item and make a second separate call to op get item.

    the CLI mechanism doesn't seem to be appropriate to call from a script (interactively prompts for user's master password)

    The best way to enter your 1Password account's password is to do so interactively using op. You can also pipe your Master Password in – the simplest example I can imagine of this is the following:

    $ eval $(echo "<password>" | op signin)
    

    However, using echo for this is not a good idea. Figuring out how to secure your Master Password outside of op is likely to be tricky and you'll need to consider this point carefully.

    You can find more details in the CLI Documentation. Let me know if that helps or if you have any questions. :smile:

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Emoji
Image
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file