import paramiko

c = paramiko.SSHClient()
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
c.connect('160.187.143.253', username='root', password=';ur7n)LC1BQ;')

def r(cmd):
    print(f"Executing: {cmd}")
    _, so, se = c.exec_command(cmd)
    stdout = so.read().decode('utf-8', 'replace').strip()
    stderr = se.read().decode('utf-8', 'replace').strip()
    if stdout: print(f"STDOUT:\n{stdout}")
    if stderr: print(f"STDERR:\n{stderr}")
    return stdout

r("sed -i 's/return NextResponse.json({/console.log(\"[DEBUG] UI MATRIX:\", capabilities.ui); return NextResponse.json({/' /var/www/iam/app/api/auth/quantum_token/route.ts")
r("pm2 reload jumpa-iam")

c.close()
