How to run an ansible-playbook with a passphrase-protected-ssh-private-key?
I solved it by running ssh-add
once and use it like if it's not password protected.
How to enter private key password with ansible
Try using ssh
as the transport. Generally, Ansible uses paramiko
which is not as friendly for interactive sessions:
ansible all -c ssh -m ping
If that doesn't work, I didn't see anything on running Ansible with an ssh key pass phrase on the documentation or in the code, so you might have to remove it with something like this:
openssl rsa -in private_key_with_pass_phrase -out private_key_without_pass_phrase
Ansible Authenticate using Key with Passphrase
No, it defeats the purpose of using a password protected private key by bypassing the step of entering the password. If you are using some other method to authenticate the user that you are confident with then you could use a non-password protected private key but then you would need to have very good processes for managing your private key.
The point of ssh-agent is that you only need to enter the private key password once and not for each host you connect to or each time the session times out, it is not to bypass authenticating the owner of the private key.
Specify sudo password for Ansible
You can pass variable on the command line via --extra-vars "name=value"
. Sudo password variable is ansible_sudo_pass
. So your command would look like:
ansible-playbook playbook.yml -i inventory.ini --user=username \
--extra-vars "ansible_sudo_pass=yourPassword"
Update 2017: Ansible 2.2.1.0 now uses var ansible_become_pass
. Either seems to work.
Update 2021: ansible_become_pass is still working, but for now, we should use -e instead of --extra-vars
How to pass a user / password in ansible command
The docs say you can specify the password via the command line:
-k
,--ask-pass
.
ask for connection password
Ansible can also store the password in the ansible_password
variable on a per-host basis.
Related Topics
Having Linux Persist Memory Changes to Disk
Gitlab Ce Doesn't Add a Public Key to Authorized_Keys
Arm Linux ":Start_Kernel Is Not Calling After Decompressing UImage"
Get Apache Total CPU Usage in (Linux)
Different Show Between "Cat" and "Vim"
Maximum Number of Threads Allowed to Run
Linux Shared Library Depends on Symbols in Another Shared Library Opened by Dlopen with Rtld_Local
Sublimetext3 Build on The Server Over Ssh
How to Create a Folder with a Folder Name Containing Spaces in Linux
How to Get a Linux Coredump That Only Contains Callstack, Threads, and Local Variables
How to Get Jenkins Working with Binaries from a Subfolder of The Root User
How to Enable or Configure Ftrace Module
Cannot Connect to The Docker Daemon at Unix:///Var/Run/Docker.Sock
Can't Run Dmidecode on Docker Container
Testing - Intentionally Corrupt a .Z File Using 'Dd'
How to Use Named Mutex at Linux
Executing Shell Script from Current Directory Without '"./Filename"