Non-standard Ansible Port

Red Hat Ansible Red Hat Ansible

If you plan on starting with Ansible any time soon, one thing you can really appreciate is that prior to having a smooth post-configuration process you’re going to configure a number of pre-existing servers, all from different periods and possibly running different operating systems. Some might even use different SSH port.

Ansible uses SSH

As you know, Ansible uses standard SSH port for connecting to Unix/Linux servers remotely. Default SSH port is 22, but it’s possible to configure SSH to use some other port – and this becomes a problem because Ansible can’t connect to such hosts.

Specify non-standard SSH port in Ansible

It’s fairly easy to make Ansible recognise that some server needs to be accessed using a different port. Simply expand your Ansible hosts entry from something like this (you’re going to have different hostname and IP address, most likely):

s7      ansible_host=

To this:

s7      ansible_host=       ansible_port=202

That’s all there is to it! Enjoy!

See Also

Keep Learning

Follow me on Facebook, Twitter or Telegram:
I learn with Educative: Educative I'm also a fan of SetApp for macOS: SetApp for macOS
IT Consultancy
I'm a principal consultant with Tech Stack Solutions. I help with cloud architectrure, AWS deployments and automated management of Unix/Linux infrastructure. Get in touch!

Recent Tweets