private void btnCMD_Click(object sender, EventArgs ee)
        {
            try
            {
                //  SshConnectionInfo input = Util.GetInput();
                SshExec exec = new SshExec(txtHost.Text, txtUser.Text);
                exec.Password = txtPassword.Text;
                //  if (input.Pass != null) exec.Password = input.Pass;
                //   if (input.IdentityFile != null) exec.AddIdentityFile(input.IdentityFile);

                AppendText("Connecting...");
                exec.Connect();
                AppendText("Connect OK");

                string command = txtCMD.Text;
                if (command != "")
                {
                    exec.RunCommand(command);
                }

                AppendText("Disconnecting...");
                exec.Close();
                AppendText(" Disconnecting OK");
            }
            catch (Exception e)
            {
                AppendText(e.Message);
            }
        }
Esempio n. 2
0
 void Command.issueCommand()
 {
     exec.Connect();
     exec.RunCommand("sudo reboot");
     exec.Close();
     return;
 }
Esempio n. 3
0
        public void Test_Vagrant_Connect()
        {
            SshConnectionInfo input = UserInput;

            SshShell shell = new SshShell(input.Host, input.User);

            if (input.Pass != null)
            {
                shell.Password = input.Pass;
            }
            if (input.IdentityFile != null)
            {
                shell.AddIdentityFile(input.IdentityFile);
            }

            //This statement must be prior to connecting
            shell.RedirectToConsole();

            Console.Write("Connecting...");
            shell.Connect();
            Console.WriteLine("OK");

            // SSH-2.0-OpenSSH_6.6.1p1 Ubuntu-2ubuntu2
            Console.WriteLine("server=" + shell.ServerVersion);

            SshExec shellExec = null;

            if (shell.ShellOpened)
            {
                // shell.Close();

                shellExec = SshExec.Clone(shell);
                // new SshExec(shell.Host, shell.Username, shell.Password);
                shellExec.Connect();
            }

            if (shellExec != null && shellExec.Connected)
            {
                var session = shellExec.Session;
                var channel = shellExec.Channel;
                Console.WriteLine(session);
                Console.WriteLine(channel);

                var stream = shellExec.RunCommandEx("ls -l", true);
                // = shell.StreamASCII();
                while (stream.MoveNext())
                {
                    Console.WriteLine(stream.Current);
                }

                System.Threading.Thread.Sleep(500);
            }

            Console.Write("Disconnecting...");
            if (shellExec != null)
            {
                shellExec.Close();
            }
            Console.WriteLine("OK");
        }
Esempio n. 4
0
        public void ExecuteCommand(String command)
        {
            using (var ssh = new SshExec(host, user, pass))
            {
                ssh.Connect();

                ssh.RunCommand(command);
            }
        }
Esempio n. 5
0
        public void ExecuteCommand(String command)
        {
            using (var ssh = new SshExec(host, user, pass))
            {
                ssh.Connect();

                ssh.RunCommand(command);
            }
        }
Esempio n. 6
0
        }     // end EjecutarSHH

        public static string test()
        {
            //Establecemos la conexión SSH
            const string host    = "tmpsao445674";
            SshExec      sshExec = new SshExec(host, "tomcat", "XXXsrivera445674");

            sshExec.Connect();

            string result = sshExec.RunCommand(@"cat /etc/redis.conf");

            return(result);
        }
Esempio n. 7
0
        void Command.issueCommand()
        {
            exec.Connect();

            Console.WriteLine("Creating directories...");
            CreateDirectories();

            Console.WriteLine("Transferring scripts...");
            TransferScripts();

            Console.WriteLine("Running install script...");
            RunScripts();
        }
Esempio n. 8
0
 public SSHOperation(string DDEI_IP, string SSH_ROOT, string SSH_PASS)
 {
     shell = new SshExec(DDEI_IP, SSH_ROOT, SSH_PASS);
     try
     {
         shell.Connect();
     }
     catch (Exception e)
     {
         Console.WriteLine("Error happened when SSH connect to DDEI! [{0}]", e.Message);
         throw new Exception("SSH connection fail!");
     }
 }
Esempio n. 9
0
        private static void OpenSshConnection()
        {
            ssh = new SshExec(host, user, password);
            ssh.Connect(sshPort);
            Console.WriteLine("Connected");

            sftpBase = new Tamir.SharpSsh.Sftp(host, user, password);
            sftpBase.OnTransferStart += new FileTransferEvent(sftpBase_OnTransferStart);
            sftpBase.OnTransferEnd   += new FileTransferEvent(sftpBase_OnTransferEnd);
            Console.WriteLine("Trying to Open Connection...");
            sftpBase.Connect(sshPort);
            Console.WriteLine("Connected Successfully !");
        }
Esempio n. 10
0
        public static void syncKioskoLinux(string host, string imageFolder, string videoFolder, string numTienda,
                                           ProgressTaskEventArgs e, int progActual, int razonCambio)
        {
            SshExec exec;
            SshTransferProtocolBase sshCp;

            exec           = new SshExec(host, kioskoUser);
            sshCp          = new Sftp(host, kioskoUser);
            exec.Password  = kioskoPass;
            sshCp.Password = kioskoPass;

            progActual += razonCambio;
            exec.Connect();
            e.UpdateProgress(progActual);

            progActual += razonCambio;
            sshCp.Connect();
            e.UpdateProgress(progActual);

            string imageLocalPath = String.Format("{0}{1}", kioskoRepository, imageFolder);
            string videoLocalPath = String.Format("{0}{1}", kioskoRepository, videoFolder);
            string xmlLocalPath   = String.Format("{0}{1}", pathToTemp, "kioskoXML");

            OneWayFolderSyncSSH imageSync = new OneWayFolderSyncSSH(exec, sshCp, imageLocalPath, kioskoPathToImages);
            OneWayFolderSyncSSH videoSync = new OneWayFolderSyncSSH(exec, sshCp, videoLocalPath, kioskoPathToVideos);
            OneWayFolderSyncSSH xmlSync   = new OneWayFolderSyncSSH(exec, sshCp, xmlLocalPath, kioskoPathToXML);
            XmlKioskoLinux      xmlKiosko = new XmlKioskoLinux(kioskoPathToImages, kioskoPathToVideos, pathToTemp, numTienda, exec);

            progActual += razonCambio * 2;
            imageSync.syncFiles("*.jpg");
            e.UpdateProgress(progActual);

            progActual += razonCambio * 2;
            videoSync.syncFiles("*.flv");
            e.UpdateProgress(progActual);

            progActual += razonCambio;
            xmlKiosko.generateServerXML(host);
            xmlKiosko.generateImageXML();
            xmlKiosko.generateVideoXML();
            e.UpdateProgress(progActual);

            progActual += razonCambio;
            xmlSync.syncFiles("*.xml");
            e.UpdateProgress(progActual);

            progActual += razonCambio;
            exec.Close();
            sshCp.Close();
            e.UpdateProgress(progActual);
        }
        private String getMeLastModificationTime(String serverPath)
        {
            String stdOut = null;
            String stdErr = null;
            // need to send following cmd: stat serverPath | grep -E ^M | cut -d' ' -f2
            String cmdToExec = "stat " + serverPath + " | grep -E ^M | cut -d' ' -f2";

            mySshExec = new SshExec(ftpAdr, user, password);
            mySshExec.Connect();
            mySshExec.RunCommand(cmdToExec, ref stdOut, ref stdErr);
            mySshExec.Close();
            //Debug.Print("Data pliku na serwerze " + stdOut);
            return(stdOut);
        }
Esempio n. 12
0
        public XmlKioskoLinux(string imgFolder, string videoFolder, string tempFileFolder, string numTienda, string host, string user, string password)
        {
            this.imgFolder      = imgFolder;
            this.videoFolder    = videoFolder;
            this.tempFileFolder = tempFileFolder;
            this.numTienda      = numTienda;


            exec          = new SshExec(host, user);
            exec.Password = password;
            exec.Connect();

            initVars();
        }
Esempio n. 13
0
        public void Start(RemoteDevice target)
        {
            //hacky but openssh seems to ignore signals
            Action start = delegate
            {
                var startexec = new SshExec(target.target.ToString(), target.username, target.password);
                startexec.Connect();
                var result = startexec.RunCommand("mono /root/FlightControl/FlightControl.exe");

                startexec.Close();
            };

            start.Invoke();
        }
Esempio n. 14
0
        public override DTSExecResult Execute(Connections connections, VariableDispenser variableDispenser, IDTSComponentEvents componentEvents, IDTSLogging log, object transaction)
        {
            ConnectionManager conn = getCurrentConnectionManager(connections);
            List <KeyValuePair <string, string> > connParams = (List <KeyValuePair <string, string> >)conn.AcquireConnection(transaction);

            string host     = connParams.Find(t => t.Key == "Host").Value;
            string username = connParams.Find(t => t.Key == "Username").Value;
            string password = connParams.Find(t => t.Key == "Password").Value;
            int    port     = Convert.ToInt32(connParams.Find(t => t.Key == "Port").Value);

            SshExec exec = new SshExec(host, username);

            exec.Password = password;

            try
            {
                string stdOut = string.Empty;
                string stdErr = string.Empty;
                exec.Connect();
                StringReader sr = new StringReader(_commandText);
                while (true)
                {
                    string s = sr.ReadLine();
                    if (s != null && stdErr.Trim().Length == 0)
                    {
                        int res = exec.RunCommand(s, ref stdOut, ref stdErr);
                    }
                    else
                    {
                        if (stdErr.Trim().Length > 0)
                        {
                            fireError(componentEvents, stdErr);
                            return(DTSExecResult.Failure);
                        }
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                fireError(componentEvents, ex.Message);
                return(DTSExecResult.Failure);
            }
            finally
            {
                exec.Close();
            }
            return(DTSExecResult.Success);
        }
Esempio n. 15
0
        private string runStatusCommand(SshShell shell, SshExec exec, string command)
        {
            string stdout = "";
            string stderr = "";

            shell.Connect();
            shell.RedirectToConsole();
            exec.Connect();

            int ret = exec.RunCommand(command, ref stdout, ref stderr);

            exec.Close();
            shell.Close();
            return(stdout);
        }
Esempio n. 16
0
        public void Kill(RemoteDevice target)
        {
            //hacky but openssh seems to ignore signals
            Action kill = delegate
            {
                var killExec = new SshExec(target.target.ToString(), target.username, target.password);
                killExec.Connect();
                var killcmd = @"killall mono";
                var result  = killExec.RunCommand(killcmd);
                result = killExec.RunCommand("killall FCRestarter");
                killExec.Close();
            };

            kill.Invoke();
        }
Esempio n. 17
0
        public void runCommand(string command, string stdout = "", string stderr = "")
        {
            _shell.Connect();
            _shell.RedirectToConsole();
            _exec.Connect();

            int ret = _exec.RunCommand(command, ref stdout, ref stderr);

            if (ret != 0)
            {
                System.Diagnostics.Debugger.Break();
            }

            _exec.Close();
            _shell.Close();
        }
Esempio n. 18
0
        public void RunShellTest()
        {
            try
            {
                shell.Connect();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            shell.ExpectPattern = "#";
            Console.WriteLine(shell.Expect());
            shell.WriteLine(@"ls");
            Console.WriteLine(shell.Expect());
            shell.WriteLine(@"ll");
            Console.WriteLine(shell.Expect());
            shell.WriteLine(@"cd /usr/local");
            Console.WriteLine(shell.Expect());
            shell.WriteLine(@"ll");
            Console.WriteLine(shell.Expect());
            shell.WriteLine(@"topp");
            Console.WriteLine(shell.Expect());

            shell.Close();


            Console.WriteLine("----------------------------------------------");

            exec.Connect();
            string strRrr = "";
            string strOut = "";

            exec.RunCommand("ls", ref strOut, ref strRrr);
            System.Threading.Thread.Sleep(1000);
            Console.WriteLine(strOut);
            Console.WriteLine(strRrr);

            exec.RunCommand(@"cd /usr/local", ref strOut, ref strRrr);
            Console.WriteLine(strOut);
            Console.WriteLine(strRrr);


            Console.WriteLine(exec.RunCommand(@"ll"));
            Console.WriteLine(exec.RunCommand(@"cd /usr/local"));

            exec.Close();
        }
Esempio n. 19
0
        // This should only be run for sequencing jobs, i.e. those requiring PhRed validation.
        // run phred
        private void RunPhred(int barcode)
        {
            // list of commands to execute
            // cp -R /mnt/cgfdata/raw/{barcode} /home/caesdev/raw
            // mkdir /home/caesdev/output/{barcode}
            // /opt/pkg/genome/bin/phred -id /home/caesdev/raw/{barcode} -qd /home/caesdev/output/{barcode}
            // cp -R /home/caesdev/output/{barcode} /mnt/cgfdata/output

            string output = null, error = null;

            var ssh = new SshExec(PhredServer, PhredUsername, PhredPassword);

            ssh.Connect();

            try
            {
                // copy in data
                //ssh.RunCommand(string.Format(@"cp -R /mnt/cgfdata/raw/{0} /home/{1}/raw", barcode, PhredUsername));
                ssh.RunCommand(string.Format(@"cp -R /mnt/cgfdata/Backup/raw/{0} /home/{1}/raw", barcode, PhredUsername));
                ssh.RunCommand(string.Format(@"mkdir /home/{0}/output/{1}", PhredUsername, barcode));

                // execute
                ssh.RunCommand(string.Format(@"/opt/pkg/genome/bin/phred -id /home/{0}/raw/{1} -qd /home/{0}/output/{1}", PhredUsername, barcode), ref output, ref error);

                if (!string.IsNullOrEmpty(error))
                {
                    throw new Exception(error);
                }

                // clean up
                //ssh.RunCommand(string.Format(@"mv /home/{0}/output/{1} /mnt/cgfdata/output", PhredUsername, barcode));
                ssh.RunCommand(string.Format(@"mv /home/{0}/output/{1} /mnt/cgfdata/Backup/output", PhredUsername, barcode));
                ssh.RunCommand(string.Format(@"rm /home/{0}/raw/{1}/*", PhredUsername, barcode));
                ssh.RunCommand(string.Format(@"rmdir /home/{0}/raw/{1}", PhredUsername, barcode));
            }
            catch
            {
                // automatic cleanup
                ssh.RunCommand(string.Format(@"rm /home/{0}/output/{1}/*", PhredUsername, barcode));
                ssh.RunCommand(string.Format(@"rmdir /home/{0}/output/{1}", PhredUsername, barcode));
                ssh.RunCommand(string.Format(@"rm /home/{0}/raw/{1}/*", PhredUsername, barcode));
                ssh.RunCommand(string.Format(@"rmdir /home/{0}/raw/{1}", PhredUsername, barcode));
            }

            ssh.Close();
        }
Esempio n. 20
0
        public OneWayFolderSyncSSH(string host, string user, string password, string localFolder, string remoteFolder)
        {
            this.localFolder  = localFolder;
            this.remoteFolder = remoteFolder;

            this.localFiles  = new ArrayList();
            this.remoteFiles = new ArrayList();

            exec  = new SshExec(host, user);
            sshCp = new Tamir.SharpSsh.Sftp(host, user);

            exec.Password  = password;
            sshCp.Password = password;

            exec.Connect();
            sshCp.Connect();
        }
Esempio n. 21
0
        public void Test_Vagrant_ls()
        {
            SshConnectionInfo input = UserInput;

            SshExec exec = new SshExec(input.Host, input.User);

            if (input.Pass != null)
            {
                exec.Password = input.Pass;
            }
            // if(input.IdentityFile != null) exec.AddIdentityFile( input.IdentityFile );

            Console.Write("Connecting...");
            exec.Connect();
            Console.WriteLine("OK");

            // while
            {
                Console.Write("Enter a command to execute ['Enter' to cancel]: ");
                string command = "ls";

                Console.WriteLine(command);

                var outputEnum = exec.RunCommandEx(command, false); // .RunCommand(command);
                while (outputEnum.MoveNext())
                {
                    Console.WriteLine(outputEnum.Current);
                }
            }

            SFTPUtil util = SFTPUtil.Clone(exec);

            var list = util.ListFiles("/");

            foreach (ChannelSftp.LsEntry line in list)
            {
                Console.WriteLine(line.Filename);
            }

            Console.Write("Disconnecting...");

            util.Dispose();
            exec.Close();
            Console.WriteLine("OK");
        }
Esempio n. 22
0
        //WPF로 파일 업로드 (localfile : 컴퓨터 파일 경로, hwak : 확장자, std_no : 학번)
        //설치 순서 주의! - packages폴더에 dll이 있어야함.
        //사용시 https://sourceforge.net/projects/sharpssh/ 에서 다운한 파일 중 'Tamir.SharpSSH.dll'을 참조 후 누겟의 Tamir.SharpSSH 설치, 그 후 앞서 참조한 dll 참조 지우기
        private void Uploadimg(string localfile, string hwak, string std_no)
        {
            Sftp oSftp = null;

            try
            {
                SshExec se = new SshExec("l.bsks.ac.kr", "p201606023", "pp201606023");
                se.Connect(22);
                string dir = "/home/p201606023/public_html/image/";
                se.RunCommand("rm " + dir + std_no + ".jpg");
                se.RunCommand("rm " + dir + std_no + ".jpeg");
                se.RunCommand("rm " + dir + std_no + ".png");
                se.RunCommand("rm " + dir + std_no + ".gif");
                se.RunCommand("rm " + dir + std_no + ".JPG");
                se.RunCommand("rm " + dir + std_no + ".PNG");
                se.RunCommand("rm " + dir + std_no + ".GIF");
                se.Close();

                string _ftpURL       = "l.bsks.ac.kr";                        //Host URL or address of the SFTP server
                string _UserName     = "******";                          //User Name of the SFTP server
                string _Password     = "******";                         //Password of the SFTP server
                int    _Port         = 22;                                    //Port No of the SFTP server (if any)
                string _ftpDirectory = "/home/p201606023/public_html/image/"; //The directory in SFTP server where the files will be uploaded

                oSftp = new Sftp(_ftpURL, _UserName, _Password);
                oSftp.Connect(_Port);

                oSftp.Put(localfile, _ftpDirectory + std_no + "." + hwak);
            }
            catch (Exception ex)
            {
                MessageBox.Show("이미지 저장에 실패하였습니다.\n" + ex.Message + "::" + ex.StackTrace, "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);

                return;
            }
            finally
            {
                if (oSftp != null)
                {
                    oSftp.Close();
                }
            }
        }
        public static SshRemoteProcess CreateProcess(MeeGoExecutionCommand cmd, string sdbOptions, MeeGoDevice device,
                                                     Dictionary <string, string> xauth,
                                                     Action <string> stdOut, Action <string> stdErr)
        {
            string exec = GetCommandString(cmd, sdbOptions, xauth);

            var ssh = new LiveSshExec(device.Address, device.Username, device.Password);

            //hacky but openssh seems to ignore signals
            Action kill = delegate {
                var killExec = new SshExec(device.Address, device.Username, device.Password);
                killExec.Connect();
                killExec.RunCommand("ps x | grep '" + cmd.DeviceExePath + "' | " +
                                    "grep -v 'grep \\'" + cmd.DeviceExePath + "\\' | awk '{ print $1 }' | xargs kill ");
                killExec.Close();
            };

            return(new SshRemoteProcess(ssh, exec, stdOut, stdErr, kill));
        }
Esempio n. 24
0
        public static void ExecuteSingleCommand(string command)
        {
            try
            {
                //create a new ssh stream
                SshExec ssh = new SshExec(MACHINE_IP, USER_NAME, PASSWORD);

                ssh.Connect();

                //writing to the ssh channel
                var str = ssh.RunCommand(command);

                ssh.Close();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
Esempio n. 25
0
        public override void ProcessCommand(OSAEMethod method)
        {
            try
            {
                string[] tmp = method.Parameter1.Split('/');
                server   = tmp[0];
                username = tmp[1];
                password = tmp[2];
                string command = method.Parameter2;
                Log.Debug("Sending command: " + command + " | " + server + " | " + username + " | " + password);
                SshExec ssh = new SshExec(server, username, password);
                ssh.Connect();

                string response = ssh.RunCommand(command);
                Log.Debug("Response: " + response);
                ssh.Close();
            }
            catch (Exception ex)
            { Log.Error("Error Sending command", ex); }
        }
Esempio n. 26
0
        private void Form1_Load(object sender, EventArgs e)
        {
            try
            {
                SshExec shell = new SshExec(ADDRESS_SERVEUR_TELNET, LOGIN_SERVEUR_TELNET, PASSWD_SERVEUR_TELNET);

                ShellBox.AppendText("Connecting...\n");

                shell.Connect();

                if (shell.Connected == true)
                {
                    ShellBox.AppendText("Connexion OK\n");

                    //while (true)
                    //{
                    System.Threading.Thread.Sleep(500);
                    string output = shell.RunCommand(@"tail -f \gsoap\log\VSSrvConnexionGS.log");
                    ShellBox.AppendText(output + "\n");
                    //}
                    ShellBox.AppendText("Disconnecting...\n");
                    shell.Close();
                    if (shell.Connected == false)
                    {
                        ShellBox.AppendText("Deconnexion OK\n");
                    }
                    else
                    {
                        ShellBox.AppendText("Deconnexion KO\n");
                    }
                }
                else
                {
                    ShellBox.AppendText("Connexion KO\n");
                }
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.Message);
            }
        }
Esempio n. 27
0
 public void Run()
 {
     try
     {
         SshConnectionInfo input = Util.GetInput();
         exec = new SshExec(input.Host, input.User);
         if (input.Pass != null)
         {
             exec.Password = input.Pass;
         }
         exec.Connect();
         string command = Console.ReadLine();
         string output  = exec.RunCommand(command);
         Console.WriteLine(output);
         exec.Close();
     }
     catch (Exception e)
     {
         Console.WriteLine(e.Message);
     }
 }
Esempio n. 28
0
        public static void RunExample()
        {
            SshConnectionInfo input = Util.GetInput();

            try
            {
                SshExec exec = new SshExec(input.Host, input.User);
                if (input.Pass != null)
                {
                    exec.Password = input.Pass;
                }
                if (input.IdentityFile != null)
                {
                    exec.AddIdentityFile(input.IdentityFile);
                }

                Console.Write("Connecting...");
                exec.Connect();
                Console.WriteLine("OK");
                while (true)
                {
                    Console.Write("Enter a command to execute ['Enter' to cancel]: ");
                    string command = Console.ReadLine();
                    if (command == "")
                    {
                        break;
                    }
                    string output = exec.RunCommand(command);
                    Console.WriteLine(output);
                }
                Console.Write("Disconnecting...");
                exec.Close();
                Console.WriteLine("OK");
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
Esempio n. 29
0
        public override void ProcessCommand(OSAEMethod method)
        {
            try
            {
                string[] tmp = method.Parameter1.Split('/');
                server   = tmp[0];
                username = tmp[1];
                password = tmp[2];
                string command = method.Parameter2;
                logging.AddToLog("Sending command: " + command + " | " + server + " | " + username + " | " + password, false);
                SshExec ssh = new SshExec(server, username, password);
                ssh.Connect();

                string response = ssh.RunCommand(command);
                logging.AddToLog("Response: " + response, false);
                ssh.Close();
            }
            catch (Exception ex)
            {
                logging.AddToLog("Error Sending command - " + ex.Message + " -" + ex.InnerException, true);
            }
        }
Esempio n. 30
0
        static void Main(string[] args)
        {
            try
            {
                SshExec exec = new SshExec(ipAddress, username, password);
                Console.Write("Connecting...");
                exec.Connect();
                Console.WriteLine("OK");
                if (exec.Connected)
                {
                    Console.WriteLine(exec.Cipher);
                }

                while (true)
                {
                    Console.Write("Enter a command to execute ['Enter' to cancel]: ");
                    string command = Console.ReadLine();
                    if (command == "")
                    {
                        break;
                    }
                    string   output = exec.RunCommand(command);
                    string[] m      = output.Split('\n');
                    for (int i = 0; i < m.Length; i++)
                    {
                        Console.WriteLine(m[i]);
                    }
                }
                Console.Write("Disconnecting...");
                exec.Close();
                Console.WriteLine("OK");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Esempio n. 31
0
        public bool Test()
        {
            bool    result = false;
            SshExec exec   = new SshExec(host, username);

            // SshShell exec = new SshShell(host, username);
            try
            {
                exec.Password = password;
                if (!string.IsNullOrEmpty(pkFile))
                {
                    exec.AddIdentityFile(pkFile);
                }
                exec.Connect();
                string output = exec.RunCommand(commandText);
                Console.WriteLine(output);
                result = true;
            }
            catch (Exception)
            {
                result = false;
            }
            finally
            {
                try
                {
                    if (exec != null && exec.Connected)
                    {
                        exec.Close();
                    }
                }
                catch
                {
                }
            }
            return(result);
        }