I am trying to add a 1Password account through a bash script to do further operations but `op account add` doesn't have --password flag as an option.
Reference - https://developer.1password.com/docs/cli/sign-in-manually
I get this error: Enter the password for ..... at ***.1password.com: [ERROR] 2022/11/29 02:53:01 inappropriate ioctl for device
How do I specify the password so that there's no intervention from `op account add` command to prompt for the password?
Hi,
The expect script must call your bash script and then pass the password (directly or using a option/secure option), let me share an example:
Your Script (stored in your file system):
#!/bin/bash
echo "please type your password:"
read password
echo "the password is: $password"
The Expect Script (defined as inline script in this example):
spawn /path/to/your/simple/bash/script.sh
expect "please type your password:\r"
send -- "1234\r"
expect eof
Let’s do that using a Rundeck job using an option to pass the password:
- defaultTab: nodes
description: ''
executionEnabled: true
id: 33258b42-89fc-4c43-a4c4-041316e6aa23
loglevel: INFO
name: HelloWorld
nodeFilterEditable: false
options:
- name: password
required: true
plugins:
ExecutionLifecycle: null
scheduleEnabled: true
sequence:
commands:
- interpreterArgsQuoted: false
script: |-
spawn /path/to/your/simple/bash/script.sh
expect "please type your password:\r"
send -- "1234\r"
expect eof
scriptInterpreter: /usr/bin/expect
keepgoing: false
strategy: node-first
uuid: 33258b42-89fc-4c43-a4c4-041316e6aa23
You can see an amazing explanation here.
Greetings.
This is the right example job definition, the previous one passes “1234” string, my bad:
- defaultTab: nodes
description: ''
executionEnabled: true
id: 33258b42-89fc-4c43-a4c4-041316e6aa23
loglevel: INFO
name: HelloWorld
nodeFilterEditable: false
options:
- name: password
required: true
plugins:
ExecutionLifecycle: null
scheduleEnabled: true
sequence:
commands:
- interpreterArgsQuoted: false
script: |-
spawn /path/to/your/simple/bash/script.sh
expect "please type your password:\r"
send -- "@option.password@\r"
expect eof
scriptInterpreter: /usr/bin/expect
keepgoing: false
strategy: node-first
uuid: 33258b42-89fc-4c43-a4c4-041316e6aa23
Regards!