using Renci.SshNet;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection.PortableExecutable;
using System.Text;
using System.Threading.Tasks;

namespace NetPanel.Bl
{
    public class SshBl
    {

        private string _username = "";
        private string _pwd = "";
        private string _host = "";

        private SshClient client = null;

        public SshBl(string host, string username, string pwd)
        {
            _username = username;
            _pwd = pwd;
            _host = host;
            client = new SshClient(host, username, pwd);
            client.Connect();
        }



        public StreamReader RunCommand(string command)
        {
            var sshCommand = client.CreateCommand(command);
            var asyncExecute = sshCommand.BeginExecute();
            return new StreamReader(sshCommand.OutputStream);
            //string outStr;
            //while ((outStr = reader.ReadLine()) != null)
            //{

            //}
        }


        /// <summary>
        /// 关闭
        /// </summary>
        public void Dispose()
        {
            client.Disconnect();
            client.Dispose();
        }
    }
}
