Skip to content

Instantly share code, notes, and snippets.

@ganny26
Created May 29, 2021 10:11
Show Gist options
  • Save ganny26/452edb33b6a1d169a27250675622e2e8 to your computer and use it in GitHub Desktop.
Save ganny26/452edb33b6a1d169a27250675622e2e8 to your computer and use it in GitHub Desktop.
kerberos.py
import os
import logging
import datetime
class Kerberos:
def __init__(self, username, keytabpath):
self.username = username
self.keytabpath = keytabpath
def create_ticket(self):
command = (
"kinit "
+ self.username
+ "@xyz.domain.com"
+ " -k -t "
+ self.keytabpath
)
logging.info("Creating ticket ... %s", command)
result = os.system(command)
logging.info("Ticket created")
return result
def list_kerberos(self):
command = "klist -kt " + self.keytabpath
result = os.popen(command).read()
return result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment