Created
May 29, 2021 10:11
-
-
Save ganny26/452edb33b6a1d169a27250675622e2e8 to your computer and use it in GitHub Desktop.
kerberos.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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