Bootstrap FreeKB - Ansible - --ask-pass (SSH) command line flag
Ansible - --ask-pass (SSH) command line flag

Updated:   |  Ansible articles

If you are using basic auth to connect to target servers (username / password), this is typically first done with the --ask-pass command line flag, during testing/development. The --ask-become-pass flag can be used to prompt Ansible for your SSH password when making a connection to a host that requires elevated privileges, such as sudo.

ansible all -m ping --ask-pass

 

Which should produce a prompt asking for your SSH password.

SSH password:

 

If the SSH connection and ping are successful, the following should be displayed.

server1.example.com | SUCCESS => {	
    "changed": false,
    "ping": "pong" 
}

 

Once your testing/development is done, there often is a need to figure out how to make the SSH connection without the --ask-pass command line flag. You could configure the default hosts file with your SSH username and password, but this isn't ideal, since your cleartext SSH password would be in the default hosts file.

Or, better yet, create a vault encrypted file that contains your SSH username and password in group_vars or a vault encrypted file that contains your SSH username and password in vars_files

Or, even better yet, you may be able to use passwordless SSH key authentication. Check out my article Ansible - Getting Started with SSH for more details on this.




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter 04448d in the box below so that we can be sure you are a human.