Ejemplo n.º 1
0
 private void CloseShell()
 {
     m_conn.Close();
     m_conn    = null;
     m_treader = null;
     m_stream  = null;
 }
Ejemplo n.º 2
0
        private void OpenShell()
        {
            m_cmdLineAdapter = Dialect.CreateCmdLineAdapter();
            m_stream         = new PipeStream();
            //m_reader = new StreamReader(m_stream);
            SSHConnectionParameter f = new SSHConnectionParameter();

            f.UserName           = Params.SshLogin;
            f.Password           = Params.SshPassword;
            f.Protocol           = SSHProtocol.SSH2;
            f.AuthenticationType = AuthenticationType.Password;
            f.WindowSize         = 0x1000;
            m_treader            = new STunReader(m_stream);
            Socket s = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);

            s.Connect(Params.SshHost, Params.SshPort);
            m_conn = SSHConnection.Connect(f, m_treader, s);

            m_treader.Channel = m_conn.OpenShell(m_treader);

            //SSHConnectionInfo ci = m__conn.ConnectionInfo;

            //byte[] b = new byte[1];
            //while (true)
            //{
            //    int input = System.Console.Read();

            //    b[0] = (byte)input;
            //    //Debug.WriteLine(input);
            //    reader._pf.Transmit(b);
            //}


            //m_shell = new SshShell(Params.SshHost, Params.SshLogin);
            //if (!String.IsNullOrEmpty(Params.SshPassword)) m_shell.Password = Params.SshPassword;
            //if (!String.IsNullOrEmpty(Params.IdentifyFile)) m_shell.AddIdentityFile(Params.IdentifyFile);
            //m_shell.Connect(Params.SshPort);
            //m_shell.WriteLine("echo AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA");
            //m_instream = new PipeStream();
            //m_outstream = new PipeStream();
            //m_outstream.BlockLastReadBuffer = false;
            //m_shell.SetStream(m_instream, m_outstream);
            ////m_stream = m_shell.GetStream();
            ////m_shell.m_instream = (PipedInputStream)((CombinedStream)m_stream).InputStream;
            //m_reader = new StreamReader(m_outstream);
            //ConsumeOutput();
        }