Does your target server require port knocking to enable SSH access? No problem.

You can try this handy ssh_pkn connection plugin. It is based on Ansible stock ssh plugin. It tries to make TCP connection to a given list of ports on the target host at the very beginning of connection creation process.

Sample inventory:



This will knock to, then to just before first SSH connection is being made.

You can also set knock_delay parameter – plugin will wait this number of seconds after each knock. Default delay is 0.5 seconds.

Get ssh_pkn plugin here.

Drop it into connection_plugins and you are good to go.