import paramiko c = paramiko.SSHClient() c.set_missing_host_key_policy(paramiko.AutoAddPolicy()) c.connect('140.44.4.71', username='root', key_filename=r'C:\Users\Snarf\.ssh\id_ed25519_snarfnet', timeout=10) py_script = """import sqlite3 conn = sqlite3.connect('/mnt/swarm_shared/legacy_volumes/gotify/gotify.db') cur = conn.cursor() print('=== APPLICATIONS ===') cols = [c[1] for c in cur.execute('PRAGMA table_info(applications)').fetchall()] print('Cols:', cols) for r in cur.execute('SELECT * FROM applications').fetchall(): print(r) """ stdin, stdout, stderr = c.exec_command("cat > /tmp/inspect_gotify.py && python3 /tmp/inspect_gotify.py") stdin.write(py_script) stdin.close() print(stdout.read().decode()) print(stderr.read().decode()) c.close()