How can I update or create with OP a Login?

I try to store login information via a bash file. How can I create or update login information in an vault?


1Password Version: Not Provided
Extension Version: Not Provided
OS Version: Not Provided
Sync Type: Not Provided
Referrer: forum-search:How can I update or create with OP a Login?

Comments

  • cohixcohix

    Team Member

    @hayo we currently do not support updating items with op, but here are the instructions to create an item: https://support.1password.com/command-line/#create-an-item

  • hayohayo
    edited July 23

    Hi cohix,
    thanks. For anyone who is looking here a short script:

    delete for existing login

    uuid=$(op get item "${LOGIN_TITLE}" --vault="${VAULT_NAME}" | jq '(.uuid)' | sed 's/\"//g')
    if [ -n "$uuid" ]
    then
    op delete item $uuid
    fi

    create new login information

    login=$( op get template login )
    login_user=$( echo $login | jq --arg USER "$USER" -c '.fields[0].value = $USER ')
    login_user_pw=$( echo $login_user | jq --arg PW "$PW" -c '.fields[1].value = $PW' )
    encoded_login=$( echo $login_user_pw | op encode )

    save in vault

    op create item Login $encoded_login --title="$LOGIN_TITLE" --vault="$VAULT_NAME"
    echo '1Password Login updated for '${USER}'

  • ag_anaag_ana

    Team Member

    Thank you for sharing this! :+1:

Leave a Comment

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