public SshShell createShell(String termType, int colWidth, int rowHeight, int pixWidth, int pixHeight, byte[] terminalModes) throws SshException { try { ChannelShell channel = (ChannelShell) session.openChannel("shell"); if (termType != null) { channel.setTerminalMode(terminalModes == null || terminalModes.length == 0 ? new byte[0] : terminalModes); channel.setPtyType(termType, colWidth, rowHeight, pixWidth, pixHeight); } return new JschSshShell(getConfiguration(), channel) { protected void onChannelClose() throws SshException { channelCount--; } protected void onShellOpen() throws SshException { channelCount++; } }; } catch (JSchException e) { throw new SshException("Failed to create shell channel.", e); } }