import 'dart:convert'; import 'package:dartssh2/dartssh2.dart'; import 'package:QuickSSH/classes/ServerCommand.dart'; class SSHService { static Future execute(ServerCommand server) async { try { // 1. Connect to the IP and Port final socket = await SSHSocket.connect( server.ip, 22, timeout: const Duration(seconds: 10), ); // 2. Authenticate final client = SSHClient( socket, username: server.username, onPasswordRequest: () => server.password, ); // 3. Run the specific command final result = await client.run(server.command); client.close(); await client.done; // 4. Return the server's response return utf8.decode(result); } catch (e) { return "Error: $e"; } } }