29 lines
791 B
Python
29 lines
791 B
Python
import paramiko
|
|
import sys
|
|
import io
|
|
|
|
if sys.platform == 'win32':
|
|
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8', errors='replace')
|
|
sys.stderr = io.TextIOWrapper(sys.stderr.buffer, encoding='utf-8', errors='replace')
|
|
|
|
HOST = "161.97.93.156"
|
|
USER = "carlos"
|
|
PASSWORD = "Innova1978+*?"
|
|
|
|
client = paramiko.SSHClient()
|
|
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
client.connect(hostname=HOST, username=USER, password=PASSWORD, timeout=30)
|
|
|
|
cmd = ' '.join(sys.argv[1:]) if len(sys.argv) > 1 else 'uptime'
|
|
stdin, stdout, stderr = client.exec_command(cmd)
|
|
|
|
out = stdout.read().decode('utf-8', errors='replace')
|
|
err = stderr.read().decode('utf-8', errors='replace')
|
|
|
|
if out:
|
|
print(out, end='')
|
|
if err:
|
|
print("[ERR]:", err, end='')
|
|
|
|
client.close()
|