Mass Update Logins/Passwords

khaosspawn
khaosspawn
Community Member
edited August 2021 in CLI

Hi There - I have the use case were I have multiple demo/sample accounts to log into a system. eg. dave, vicki, john - and all these accounts have the same password which is changed every few days.

Is there any way I can bulk update all the passwords in 1Password for these logins?


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

Comments

  • ag_ana
    ag_ana
    1Password Alumni

    Hi @khaosspawn!

    You cannot do this directly in the 1Password apps I am afraid. You could however perhaps be able to do it with the CLI:

    Use the 1Password command-line tool

    Especially if the passwords change every few days, you might be able to automate this. I am not a developer, but if you have any specific questions I can ask some team members :+1:

  • khaosspawn
    khaosspawn
    Community Member

    If you could perhaps supply some examples on how to go about this - that would be very helpful. I didn't know there was a CLI.

  • ag_ana
    ag_ana
    1Password Alumni

    @khaosspawn:

    Sure, I have moved the discussion to the CLI section of the forum, and I have reached out to the team to see if they have any examples :+1:

  • khaosspawn
    khaosspawn
    Community Member

    Thanks @ag_ana! Will be very helpful to review some examples. I'm guessing I'd need to put all the affected items into a specific vault or add a tag.

  • ag_ana
    ag_ana
    1Password Alumni

    @khaosspawn:

    The team suggested I share with you this section of the documentation:

    edit item

    I'm guessing I'd need to put all the affected items into a specific vault or add a tag.

    Adding a tag sounds like a good way to mark all of the items you want to update, since you also can filter based on that using the --tags tags option:

    list items

  • khaosspawn
    khaosspawn
    Community Member

    I had an attempt to write up a script to update a bunch of items. Happy to get any feedback for automating grabbing all the user names from a vault (I'd just hard coded them for now).

    #!/bin/zsh

    #
    # Update the demo passwords in 1password.
    #

    # Define our variables
    new_password="THIS IS THE NEW PASSWORD"
    user_names=(
    "aa"
    "bb"
    "cc"
    "dd"
    )
    vault="Vault A"

    # Sign in
    # In case the details aren't stored use the command below to initialize it
    # op signin abc.1password.com abc@def
    eval $(op signin abc)

    # Let's update all the users
    for user_name in "${user_names[@]}"; do
    echo "Updating: $user_name"
    op edit item "$user_name" --vault "${vault}" password=$new_password
    echo "Update complete"
    done

    op signout

  • ag_yaron
    ag_yaron
    1Password Alumni
    edited August 2021

    Hey @khaosspawn ,
    Looks like you built a nice script there!

    If you want to automate it a bit further, instead of manually listing every username, try using tags:

    1. Add a unique tag to all affected items (e.g. "NeedsPasswordChange").
    2. In the script, list all items that contain that tag: op list items --tags NeedsPasswordChange
    3. Instruct the script to grab the UUID of each item in the output of the above command and store it in the array in the script, then run the rest of the script.

    You might also add some other flags to make it faster/more efficient. For example, if you specify in which vault the items are in, it will retrieve them quicker because it won't go over all vaults in the account, so add --vault NameOfVault to the command in step #2.

    Adding the --cache flag will also further enhance performance as it will cache all the data temporarily in your computer instead of having to call our servers for every command, so add that flag as well to the command in step #2. Use the --cache flag in every op command afterwards to keep using the (temporary) locally stored data.

    Eventually the command would like similar to this: op list items --tags NeedPasswordChange --vault NameOfVault --cache

This discussion has been closed.