14 lines
561 B
Python
Executable File
14 lines
561 B
Python
Executable File
import paramiko, sys
|
|
host, user, password, cmd = sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4]
|
|
ssh = paramiko.SSHClient()
|
|
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
try:
|
|
ssh.connect(host, username=user, password=password, timeout=30)
|
|
stdin, stdout, stderr = ssh.exec_command(cmd, timeout=30)
|
|
sys.stdout.write(stdout.read().decode("utf-8", errors="replace"))
|
|
sys.stderr.write(stderr.read().decode("utf-8", errors="replace"))
|
|
ssh.close()
|
|
except Exception as e:
|
|
print(f"SSH_ERROR: {e}", file=sys.stderr)
|
|
sys.exit(1)
|