Skip to main content
Nov 29, 2022 3:04 AM UTC
Question

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

Jack_P_1P
1Password Employee
1Password Employee
Nov 30, 2022 8:17 PM UTC

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

Mar 30, 2023 12:06 AM UTC

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

May 26, 2023 4:08 PM UTC

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