File size: 1,240 Bytes
7240b31 19f68b8 825bf33 7240b31 19f68b8 7240b31 19f68b8 7240b31 19f68b8 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
import paramiko
import gradio as gr
def ssh_execute(hostname, username, password, command):
try:
client = paramiko.SSHClient()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
client.connect(hostname, username=username, password=password)
stdin, stdout, stderr = client.exec_command(command)
result = stdout.read().decode()
error = stderr.read().decode()
client.close()
return result if result else error
except Exception as e:
return str(e)
# Интерфейс для выполнения команд на сервере через SSH
interface = gr.Interface(
fn=ssh_execute,
inputs=[
gr.Textbox(label="Hostname"),
gr.Textbox(label="Username"),
gr.Textbox(label="Password", type="password"),
gr.Textbox(label="Command", placeholder="Введите команду для выполнения на сервере")
],
outputs="text",
title="SSH Выполнение Команды",
description="Введите параметры для подключения к SSH и выполнения команды."
)
if __name__ == "__main__":
interface.launch() |