Skip to main content
November 29, 2022
Question

Adding/Sign-in to an account via bash script

  • November 29, 2022
  • 3 replies
  • 639 views

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
November 30, 2022

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

March 30, 2023

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

May 26, 2023

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