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); }
public virtual void connect(PipedInputStream snk) { if (snk == null) { throw new NullReferenceException(); } else if (sink != null || snk.connected) { throw new IOException("Already connected"); } sink = snk; snk.m_in = -1; snk.m_out = 0; snk.connected = true; int t = 0; }
internal PassiveOutputStream(PipedInputStream In) : base(In) { }
/** * Creates a piped output stream connected to the specified piped * input stream. Data bytes written to this stream will then be * available as input from <code>snk</code>. * * @param snk The piped input stream to connect to. * @exception IOException if an I/O error occurs. */ public PipedOutputStream(PipedInputStream snk) { connect(snk); }
public virtual void connect(PipedInputStream snk) { if (snk == null) { throw new NullReferenceException(); } else if (sink != null || snk.connected) { throw new IOException("Already connected"); } sink = snk; snk.m_in = -1; snk.m_out = 0; snk.connected = true; int t=0; }