Reputation: 173
I am running the following command,
ansible --args="top -b n1" --connection=ssh --inventory-file=xx.xx.xxx.xxx, all --extra-vars="ansible_user=devuser" --private-key /opt/hivecenter/keys/id_rsa_135
Enter passphrase for key '/opt/hivecenter/keys/id_rsa_135':
As this key is passphrase protected it is prompting me to provide passphrase, but i want to provide passphrase in the command itself. how to do this?
Upvotes: 2
Views: 4584
Reputation: 280
If you are using Python (or don't mind to use it), you can use pexpect module to execute the Ansible command in the background and automatically pass the passphrase.
Upvotes: 0
Reputation: 291
Do you really need a passphrase for your key? If your system is secure, a passphrase isn't really necessary. Besides, sending a passphrase in cleartext in your command is not recommended, because the command will be saved in your Command Line History when you run it.
This answer might be your best choice
Another option is to use Python with the Pexpect module to execute the command and automatically send the passphrase.
Upvotes: 1