Adding/Sign-in to an account via bash script

rollsdevoted
rollsdevoted
Community Member

I am trying to add an account through a bash script to do further operations but op account add doesn't have --password flag as an option.

How do I specify the password so that there's no intervention from op account add command to prompt for the password?


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

Comments

  • Hi @rollsdevoted:

    Great question. To use 1Password CLI non-interactively, like in a script, you'll need to pipe the password into it.

    For example:

    #add the account
    eval $(echo "$PASSWORD" | op account add --address my.1password.com --email "$EMAIL" --secret-key "$SECRET_KEY")
    #sign in to the account
    eval $(echo "$PASSWORD" | op signin)
    

    This example uses a very basic way of adding the password, however, and shouldn't be stored directly in the bash script.

    Let me know how you get on with that.

    Jack

  • STH
    STH
    Community Member

    What is the process when you have an OTP enabled on the account?

  • Hello,

    I'd love to hear more about your use case. I would think you would be running commands on an already trusted device, so a OTP wouldn't be required. How are you using the CLI where this would be a requirement?

    Thank you!
    Amanda

This discussion has been closed.