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()