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=192.168.1.60

To this:

s7      ansible_host=192.168.1.60       ansible_port=202

That’s all there is to it! Enjoy!

See Also




Contact Me

Follow me on Facebook, Twitter or Telegram:
Recommended
I learn with Educative: Educative
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 Articles
03 Sep 2024

macOS Sequoia 15.0

02 Sep 2024

Video: Has This Worked Before?

24 Mar 2024

Homelab: Mac Pro 2013 32GB

Recent Tweets