import paramiko
import io

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

_, so, _ = c.exec_command('pm2 logs supreme-iam --lines 50 --nostream')
out1 = so.read().decode('utf-8', 'ignore').strip()

_, so, _ = c.exec_command('pm2 logs iam --lines 50 --nostream')
out2 = so.read().decode('utf-8', 'ignore').strip()

c.close()

with open('pm2_logs_dump.txt', 'w', encoding='utf-8') as f:
    f.write("SUPREME-IAM LOGS:\n" + out1 + "\n\nIAM LOGS:\n" + out2)
