From 6c7e7ac0e547e3be9cec69cd67c63fe746b6d007 Mon Sep 17 00:00:00 2001 From: ProxySU Date: Sat, 14 Mar 2020 12:39:54 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=8B=E8=AF=95ssh=E5=91=BD=E4=BB=A4?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=B5=8B=E8=AF=95=E7=B3=BB=E7=BB=9F=E7=8E=AF?= =?UTF-8?q?=E5=A2=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ProxySU/MainWindow.xaml.cs | 43 ++++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/ProxySU/MainWindow.xaml.cs b/ProxySU/MainWindow.xaml.cs index 28ed97a..4ba4f43 100644 --- a/ProxySU/MainWindow.xaml.cs +++ b/ProxySU/MainWindow.xaml.cs @@ -368,7 +368,7 @@ namespace ProxySU client.Connect(); if (client.IsConnected == true) { - currentStatus = "主机已登录"; + currentStatus = "主机登录成功"; textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus); Thread.Sleep(2000); } @@ -376,7 +376,7 @@ namespace ProxySU currentStatus = "检测系统是否符合安装要求......"; textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus); Thread.Sleep(2000); - currentStatus = "检测完毕,符合安装要求,布署中......"; + currentStatus = "符合安装要求,布署中......"; textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus); Thread.Sleep(2000); @@ -384,24 +384,27 @@ namespace ProxySU //client.RunCommand("apt update"); //client.RunCommand("apt install curl -y"); //client.RunCommand("bash <(curl -L -s https://install.direct/go.sh)"); - try - { - using (var sftpClient = new SftpClient(connectionInfo)) - { - sftpClient.Connect(); - MessageBox.Show("sftp信息1" + sftpClient.ConnectionInfo.ServerVersion.ToString()); - sftpClient.UploadFile(File.OpenRead("config\\config.json"),"/root/config.json", true); - sftpClient.DownloadFile("/root/id_rsa.pub", File.Create("config\\server_config.json")); - MessageBox.Show("sftp信息"+sftpClient.ConnectionInfo.ServerVersion.ToString()); - } + //try + //{ + // using (var sftpClient = new SftpClient(connectionInfo)) + // { + // sftpClient.Connect(); + // MessageBox.Show("sftp信息1" + sftpClient.ConnectionInfo.ServerVersion.ToString()); + // sftpClient.UploadFile(File.OpenRead("config\\config.json"),"/root/config.json", true); + // sftpClient.DownloadFile("/root/id_rsa.pub", File.Create("config\\server_config.json")); + // MessageBox.Show("sftp信息"+sftpClient.ConnectionInfo.ServerVersion.ToString()); + // } - } - catch(Exception ex2) - { - MessageBox.Show("sftp"+ex2.ToString()); - MessageBox.Show("sftp出现未知错误"); - } - client.RunCommand("echo 1111 >> test.json"); + //} + //catch(Exception ex2) + //{ + // MessageBox.Show("sftp"+ex2.ToString()); + // MessageBox.Show("sftp出现未知错误"); + //} + var result = client.RunCommand("uname -r"); + MessageBox.Show(result.Result); + // client.RunCommand("echo 1111 >> test.json"); + currentStatus = "安装成功"; textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus); //Thread.Sleep(2000); @@ -458,7 +461,7 @@ namespace ProxySU { progressBar.IsIndeterminate = true; } - else if (currentStatus.Contains("主机已登录") == true) + else if (currentStatus.Contains("主机登录成功") == true) { progressBar.IsIndeterminate = true; //progressBar.Value = 100;