Tamir.SharpSsh.jsch.Session.openChannel C# (CSharp) Method

openChannel() public method

public openChannel ( String type ) : Channel
type String
return Channel
		public Channel openChannel(String type) 
		{
			if(!_isConnected)
			{
				throw new JSchException("session is down");
			}
			try
			{
				Channel channel=Channel.getChannel(type);
				addChannel(channel);
				channel.init();
				return channel;
			}
			catch(Exception e)
			{
				System.Console.WriteLine(e);
			}
			return null;
		}

Usage Example

        public SshHelper(string Host, string UserName, string Password)
        {
            host = Host;
            var jsch = new JSch();
            session = jsch.getSession(UserName, host, 22);
            session.setPassword(Password);

            var config = new Hashtable { { "StrictHostKeyChecking", "no" } };
            session.setConfig(config);

            session.connect();

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

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

            var reader_pi = new PipedInputStream();
            var 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);
        }
All Usage Examples Of Tamir.SharpSsh.jsch.Session::openChannel