using Renci.SshNet; using System; using System.IO; namespace DiscordBotController { public class SSHManager { private string botIp; private string botUsername; private string password; // Add password field private SshClient client; public SSHManager(string ip, string username, string password) { botIp = ip; botUsername = username; this.password = password; // Assign the password client = new SshClient(botIp, botUsername, this.password); // Pass the password to the constructor } // ... Other methods ... public void StartBotService(Action outputCallback) { try { outputCallback("Connecting to SSH..."); client.Connect(); outputCallback("Connected to SSH."); var command = client.RunCommand("sudo systemctl start bub.service"); outputCallback("Command output: " + command.Result); } catch (Exception ex) { outputCallback("An error occurred: " + ex.Message); } finally { outputCallback("Disconnecting from SSH..."); client.Disconnect(); outputCallback("Disconnected from SSH."); } } public void StopBotService(Action outputCallback) { try { outputCallback("Connecting to SSH..."); client.Connect(); outputCallback("Connected to SSH."); var command = client.RunCommand("sudo systemctl stop bub.service"); outputCallback("Command output: " + command.Result); } catch (Exception ex) { outputCallback("An error occurred: " + ex.Message); } finally { outputCallback("Disconnecting from SSH..."); client.Disconnect(); outputCallback("Disconnected from SSH."); } } } }