ClientChannel channel;
if (sb.length() > 0) {
channel = session.createChannel("exec");
channel.setIn(new ByteArrayInputStream(sb.append("\n").toString().getBytes()));
} else {
terminal = new TerminalFactory().getTerminal();
channel = session.createChannel("shell");
channel.setIn(System.in);
((ChannelShell) channel).setupSensibleDefaultPty();
}
channel.setOut(AnsiConsole.wrapOutputStream(System.out));