Skip to content

TechDirectArchive

Hands-on IT, Cloud, Security & DevOps Insights

  • Home
  • About
  • Advertise With US
  • Contact
  • Reviews
  • Toggle search form
Home » Configuration Management Tool » How to configure Kerberos for Ansible Authentication
  • PowerShell
    How to setup PowerShell on a Linux server Scripts
  • images copy
    How to disable automatic screen lock in Ubuntu Linux Linux
  • fimage2
    How to install and configure JIRA on Linux Linux
  • Veeam backup for proxmox worker update failure
    What to know about “Failed to perform Veeam Worker Upgrade” Backup
  • cisco general
    How to update Cisco ASA Network | Monitoring
  • article 1280x720.166f8634
    Configure Windows client to obtain IP Address via a DHCP Server Windows Server
  • Featured image Two Factor Authentication
    Change Two-Factor Authentication in Microsoft 365/Office 365 Network | Monitoring
  • reset
    How to Reset a Snom Phone Network | Monitoring

How to configure Kerberos for Ansible Authentication

Posted on 14/03/202009/10/2024 Christian By Christian 2 Comments on How to configure Kerberos for Ansible Authentication
configure Kerberos

A Key Distribution Center (abbreviated KDC) is also known as the Trust Center in the Kerberos system, Kerberos server, issues an on-demand ID file(TGT) for logged-in users on request, which the user can use as an ID to protect their traffic. In this article, we shall learn how to configure Kerberos for Ansible Authentication. Please see What to note when settings up Ansible to work with Kerberos, and how to Fix cannot find KDC for realm while getting initial credentials and kinit configuration file does not specify default realm.

Ticket Granting Ticket (TGT)

The Ticket Granting Ticket (TGT) is a small file that provides access to a data exchange, similar to a password but more secure.

The TGT is considered more secure because it contains, in encrypted form, the client’s IP address, the lifetime of the TGT, and the previously generated session key, preventing a man-in-the-middle attack. Furthermore, The TGT is an essential part of the Kerberos system for data path backup.

The TGT is issued by the Key Distribution Center (KDC) for registered and designated (authenticated) users. This step is required for Kerberos to communicate with the domain effectively and this is achieved via the following path in my environment as shown below.

Modify the configuration files, krb5.conf to reflect the correct information, (such as domain-realm mappings to Kerberos servers’ names) for your realm. Edit the file using any of your desired editors and populate it as follow

C:\cygwin64\etc\crypto-policies\back-ends\krb5.config

Note: We will populate the file later, but for the initial test, this is absolutely ok.

Ansible Authentication

Authenticate to Kerberos Service

Before making your first connection in any Cygwin session. You need to authenticate to the Kerberos service. In a Cygwin bash shell, type.

kinit <yourusername>
Kerberos setup

Here, you will be prompted to enter your password. After you must have successfully authenticated, you will have acquired a Kerberos ticket-granting ticket

Now, we have tested and it works, let’s configure the Host Kerberos in details as shown below. This is necessary because Kerberos is reliant on a properly-configured environment to work.

Note: Ensure to enter the realm name in capital letters and pay specific attention to how the file is written here. Also see this lAnsible-ink for more information.

  • The [realm] should include the FQDNs of your DCs’.
  • The [domain_realm] Help map server hostname to Kerberos realm (This should include each domain that Ansible needs access to).
  • The [libdefaults] should contain various settings used by Kerberos V5 library

Ensure to save before quitting by hitting the Esc key on your keyboard, followed by “:wq” in the test editor and then hit enter on your keyboard. Below is how the file on the screenshot is layout (written).

[logging]
 default = FILE:/var/log/krb5libs.log
 kdc = FILE:/var/log/krb5kdc.log
 admin_server = FILE:/var/log/kadmind.log

[libdefaults]
 default_realm = TECHDIRECT.LOCAL
 dns_lookup_realm = false
 dns_lookup_kdc = false
 ticket_lifetime = 24h
 renew_lifetime = 7d
 forwardable = true

[realms]
 TECHDIRECT.LOCAL = {
  kdc = techdarchive.techdirect.local
  admin_server = techdarchive.techdirect.local
 }

[domain_realm]
 .techdirect.com = TECHDIRECT.LOCAL
 techdirect.com = TECHDIRECT.LOCAL 

Note (Information Only)

Most setup has it in this location /etc/krb5.conf. For seamless operation, both Kerberos and SSH can be configured. For me there was no need to configure Ansible to work with SSH, so this was ignored.

Note: There are two types of Kerberos ticket management for Ansible. We will be using the manual Kerberos ticket management

  • Automatic Kerberos Ticket management and
  • Manual Kerberos Ticket Management.

Testing: Before making your first connection to a remote device in any Cygwin session, you need to authenticate to the Kerberos service by using your Kerberized credentials In a Cygwin bash shell, type: simply run kinit binary to acquire a new Kerberos ticket as shown below.

kinit <[email protected]>

Test using kinit, it will work correctly.
$ kinit [email protected]
Password for [email protected]:
$
- You can run “klist” to list all your active Kerberos tickets and their expiration dates.)

Note: To destroy all the tickets that have been acquired, use the following command:

$ kdestroy

I hope you found this blog post on how to configure Kerberos for Ansible Authentication helpful. If you have any questions, please let me know in the comment session.

5/5 - (1 vote)

Thank you for reading this post. Kindly share it with others.

  • Click to share on X (Opens in new window) X
  • Click to share on Reddit (Opens in new window) Reddit
  • Click to share on LinkedIn (Opens in new window) LinkedIn
  • Click to share on Facebook (Opens in new window) Facebook
  • Click to share on Pinterest (Opens in new window) Pinterest
  • Click to share on Tumblr (Opens in new window) Tumblr
  • Click to share on Telegram (Opens in new window) Telegram
  • Click to share on WhatsApp (Opens in new window) WhatsApp
  • Click to share on Pocket (Opens in new window) Pocket
  • Click to share on Mastodon (Opens in new window) Mastodon
  • Click to share on Bluesky (Opens in new window) Bluesky
  • Click to share on Threads (Opens in new window) Threads
  • Click to share on Nextdoor (Opens in new window) Nextdoor
Configuration Management Tool Tags:Kerberos, Windows 10

Post navigation

Previous Post: Kinit Error: Fix Malformed representation of principal when parsing name
Next Post: How to install Kerberos packages via Cygwin in Windows

Related Posts

  • images 1
    WARNING: The provided hosts list is empty only the localhost is available and note that the implicit localhost does not match all Configuration Management Tool
  • ansible vault
    Concept of Ansible on Windows using Cygwin Configuration Management Tool
  • Create S3 Bucket with Terraform
    Create an S3 Bucket with Terraform AWS/Azure/OpenShift
  • ansible logo600 591x296 1
    Ansible_user=UNREACHABLE {Failed to connect to the host via SSH: SSH: Could not resolve hostname (Name or service not known, unreachable true) Configuration Management Tool
  • screenshot 2020 04 18 at 00.01.07
    Different ways to check for Ansible syntax errors Configuration Management Tool
  • opsworks for automate blog
    How to setup Chef Automate on AWS Configuration Management Tool

More Related Articles

images 1 WARNING: The provided hosts list is empty only the localhost is available and note that the implicit localhost does not match all Configuration Management Tool
ansible vault Concept of Ansible on Windows using Cygwin Configuration Management Tool
Create S3 Bucket with Terraform Create an S3 Bucket with Terraform AWS/Azure/OpenShift
ansible logo600 591x296 1 Ansible_user=UNREACHABLE {Failed to connect to the host via SSH: SSH: Could not resolve hostname (Name or service not known, unreachable true) Configuration Management Tool
screenshot 2020 04 18 at 00.01.07 Different ways to check for Ansible syntax errors Configuration Management Tool
opsworks for automate blog How to setup Chef Automate on AWS Configuration Management Tool

Comments (2) on “How to configure Kerberos for Ansible Authentication”

  1. Avatar photo Josh says:
    04/10/2020 at 7:34 PM

    Amazing!

    Log in to Reply
    1. chris Christian says:
      25/11/2020 at 2:07 PM

      Thank you, I am glad you found this guide useful!

      Log in to Reply

Leave a Reply Cancel reply

You must be logged in to post a comment.

Microsoft MVP

VEEAMLEGEND

vexpert-badge-stars-5

Virtual Background

GoogleNews

Categories

veeaam100

sysadmin top30a

  • PowerShell
    How to setup PowerShell on a Linux server Scripts
  • images copy
    How to disable automatic screen lock in Ubuntu Linux Linux
  • fimage2
    How to install and configure JIRA on Linux Linux
  • Veeam backup for proxmox worker update failure
    What to know about “Failed to perform Veeam Worker Upgrade” Backup
  • cisco general
    How to update Cisco ASA Network | Monitoring
  • article 1280x720.166f8634
    Configure Windows client to obtain IP Address via a DHCP Server Windows Server
  • Featured image Two Factor Authentication
    Change Two-Factor Authentication in Microsoft 365/Office 365 Network | Monitoring
  • reset
    How to Reset a Snom Phone Network | Monitoring

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 1,839 other subscribers
  • RSS - Posts
  • RSS - Comments
  • About
  • Authors
  • Write for us
  • Advertise with us
  • General Terms and Conditions
  • Privacy policy
  • Feedly
  • Telegram
  • Youtube
  • Facebook
  • Instagram
  • LinkedIn
  • Tumblr
  • Pinterest
  • Twitter
  • mastodon

Tags

AWS Azure Bitlocker Microsoft Windows PowerShell WDS Windows 10 Windows 11 Windows Deployment Services Windows Server 2016

Copyright © 2025 TechDirectArchive

 

Loading Comments...
 

You must be logged in to post a comment.