Forum Discussion

Former Member's avatar
Former Member
3 years ago

Adding/Sign-in to an account via bash script

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

3 Replies

  • Former Member's avatar
    Former Member

    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

  • Former Member's avatar
    Former Member

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

  • Jack_P_1P's avatar
    Jack_P_1P
    Icon for 1Password Team rank1Password Team

    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