29 lines
1.0 KiB
Python
29 lines
1.0 KiB
Python
import paramiko
|
|
|
|
SSH_KEY = r"C:\Users\Snarf\.ssh\id_ed25519_snarfnet"
|
|
c = paramiko.SSHClient()
|
|
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
c.connect("140.44.4.11", username="root", key_filename=SSH_KEY, timeout=10)
|
|
|
|
_, o, _ = c.exec_command("kubectl exec -n infra authentik-postgresql-0 -- cat /opt/bitnami/postgresql/secrets/password")
|
|
pw = o.read().decode().strip()
|
|
|
|
def run_sql(sql):
|
|
cmd = f"kubectl exec -i -n infra authentik-postgresql-0 -- /bin/bash -c 'export PGPASSWORD={pw}; psql -U authentik -d authentik'"
|
|
stdin, stdout, stderr = c.exec_command(cmd)
|
|
stdin.write(sql + "\n")
|
|
stdin.close()
|
|
return stdout.read().decode().strip()
|
|
|
|
print("--- APPLICATIONS ---")
|
|
print(run_sql("SELECT name, slug FROM authentik_core_application;"))
|
|
|
|
print("\n--- PROXY PROVIDERS ---")
|
|
print(run_sql("SELECT name, external_host, mode FROM authentik_providers_proxy_proxyprovider;"))
|
|
|
|
print("\n--- EXPRESSION POLICIES ---")
|
|
print(run_sql("SELECT name, expression FROM authentik_policies_expression_expressionpolicy;"))
|
|
|
|
c.close()
|
|
|