diff --git a/Program.cs b/Program.cs index d3cfb14..a9b35bc 100644 --- a/Program.cs +++ b/Program.cs @@ -303,12 +303,18 @@ namespace domain_utility do { key = Console.ReadKey(true); - if (key.KeyChar < 32 || key.KeyChar > 126) - continue; if (key.Key == ConsoleKey.Backspace && password.Length > 0) + { password = password.Substring(0, password.Length - 1); + Console.Write("\b \b"); + } + else if (key.KeyChar < 32 || key.KeyChar > 126) + continue; else if (key.Key != ConsoleKey.Backspace) + { password += key.KeyChar; + Console.Write("*"); + } } while (key.Key != ConsoleKey.Enter); Console.Write("\n\n"); @@ -321,12 +327,19 @@ namespace domain_utility int indexOfUserName = machineNameAndUser.IndexOf('\\') + 1; string machineUser = machineNameAndUser.Substring(indexOfUserName, machineNameAndUser.Length - indexOfUserName).ToLower(); - using (SshClient client = new SshClient(remote, machineUser, password)) + try { - client.Connect(); - SshCommand command = client.RunCommand(commandToExecute); - Console.WriteLine(command.Result); - client.Disconnect(); + using (SshClient client = new SshClient(remote, machineUser, password)) + { + client.Connect(); + SshCommand command = client.RunCommand(commandToExecute); + Console.WriteLine(command.Result); + client.Disconnect(); + } + } + catch (Exception ex) + { + Console.WriteLine("Произошла ошибка: " + ex.Message); } } @@ -337,6 +350,8 @@ namespace domain_utility string password = InputPassword(); + Console.WriteLine(password); + ExecuteCommandViaSSH(remote, password, "sudo sed -i 's/update_interval = 0.5,/update_interval = 300,/' /etc/conky/conky.conf"); BackToMenu(FixConky); @@ -391,7 +406,7 @@ namespace domain_utility "4 - удаленно подключиться к компьютеру (Windows -> Windows, Windows -> Linux)", // StartRDPConnection "5 - удаленная перезагрузка компьютера (только Windows)", // RemoteRebootWindows "6 - открыть CUPS выбранного компьютера (только Linux)", // OpenComputerCups - "7 - изменить время обновления conky с 0.5 на 300", // FixConky + "7 - изменить время обновления conky с 0.5 на 300 (только Linux)", // FixConky "8 - удаленная перезагрузка компьютера (только Linux)", // RemoteRebootLinux "9 - выполнить команду удаленно (только Windows -> Linux)", // ExecuteCustomCommandViaSSH };