ifixkart-backend/scripts/test_ssh_remote.py

23 lines
585 B
Python

import paramiko
host = "80.65.208.73"
user = "root"
password = "G7#Zp9!Qv@M2e$XwR8H^K"
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(host, username=user, password=password, timeout=10)
def run_remote(cmd):
print(f"Executing: {cmd}")
stdin, stdout, stderr = ssh.exec_command(cmd)
out = stdout.read().decode()
err = stderr.read().decode()
print("STDOUT:", out)
if err:
print("STDERR:", err)
return out, err
run_remote("pm2 list")
run_remote("ls -la /var/www/fastapi/ /var/www/html/")
ssh.close()