Example #1
0
        public SshHelper(string host, string username, string password)
        {
            this.host = host;
            JSch    jsch    = new JSch();
            Session session = jsch.getSession(username, host, 22);

            session.setPassword(password);

            Hashtable config = new Hashtable();

            config.Add("StrictHostKeyChecking", "no");
            session.setConfig(config);

            session.connect();

            channel = (ChannelShell)session.openChannel("shell");

            writer_po = new PipedOutputStream();
            PipedInputStream writer_pi = new PipedInputStream(writer_po);

            PipedInputStream  reader_pi = new PipedInputStream();
            PipedOutputStream reader_po = new PipedOutputStream(reader_pi);

            reader = new StreamReader(reader_pi, Encoding.UTF8);


            channel.setInputStream(writer_pi);
            channel.setOutputStream(reader_po);

            channel.connect();
            channel.setPtySize(132, 132, 1024, 768);
        }
Example #2
0
 /*
  * 把输出定向到一个指定的stream中
  */
 public void set_OutputStream(Stream stream)
 {
     m_channel.setOutputStream(stream);
 }