Getting started with 1Password for your growing team, or refining your setup? Our Secured Success quickstart guide is for you.
Forum Discussion
Former Member
3 years agoIs there a way to get one-time passwords from 1password CLI script
Hi! I'm looking for a way to automate routine tasks, like typing a 2fa code every time I connect to VPN.
Right now I'm using a https://github.com/moul/totp-keychain tool for this purpose, but I'm...
michael_c_1P
1Password Team
3 years agoYes, there are several ways you can do this. You can either use the op item get
command with the --otp
flag to return the OTP, or you can use the op read
command to read a secrets reference with the attribute query parameter. Note that secrets reference attributes are still in beta, so you'll need to be running a beta version of the CLI to use that option.
Examples:
op item get ExampleItem --otp
op read "op://development/GitHub/Security/one-time password?attribute=otp"