import paramiko import sys sys.stdout.reconfigure(encoding='utf-8') 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) script = ''' import sqlite3 con = sqlite3.connect('/var/lib/docker-data/heimdall/config/www/app.sqlite') cur = con.cursor() print("Total items:", cur.execute("SELECT count(*) FROM items").fetchone()[0]) print("Duplicates:", cur.execute("SELECT count(*), title FROM items GROUP BY title HAVING count(*) > 1").fetchall()) print("Soft-deleted items:", cur.execute("SELECT count(*) FROM items WHERE deleted_at IS NOT NULL").fetchone()[0]) print("\\nActive items (ordered):") for r in cur.execute("SELECT id, title, [order], pinned FROM items WHERE id != 0 ORDER BY [order]").fetchall(): print(" #%-2d (id: %-2d, pinned: %d): %s" % (r[2], r[0], r[3], r[1])) ''' sftp = c.open_sftp() with sftp.file('/tmp/verify_heimdall.py', 'w') as f: f.write(script) sftp.close() _, stdout, _ = c.exec_command('python3 /tmp/verify_heimdall.py') print(stdout.read().decode()) c.close()