Unable to execute command on server using j2ssh <p>I connected to a unix server through ssh and tried to execute a "ls" command and obtain it's output. The code is like this </p> <pre><code>SessionChannelClient session = client.openSessionChannel(); session.startShell(); String cmd = "ls -l"; session.executeCommand(cmd); ChannelInputStream in = session.getInputStream(); ChannelOutputStream out = session.getOutputStream(); IOStreamConnector input = new IOStreamConnector(System.in, session.getOutputStream()); IOStreamConnector output = new IOStreamConnector(session.getInputStream(), System.out); </code></pre> <p>After running I was not getting any output in log file. What I found is that the channel request is failing as shown</p> <blockquote> <p>1019 [main] INFO com.sshtools.j2ssh.connection.ConnectionProtocol - Channel request succeeded 1020 [main] INFO com.sshtools.j2ssh.session.SessionChannelClient - Requesting command execution 1021 [main] INFO com.sshtools.j2ssh.session.SessionChannelClient - Command is ls -l 1021 [main] INFO com.sshtools.j2ssh.connection.ConnectionProtocol - Sending exec request for the session channel 1021 [main] INFO com.sshtools.j2ssh.transport.TransportProtocolCommon - Sending SSH_MSG_CHANNEL_REQUEST 1021 [main] INFO com.sshtools.j2ssh.connection.ConnectionProtocol - Waiting for channel request reply 1032 [Transport protocol 1] INFO com.sshtools.j2ssh.transport.TransportProtocolCommon - Received SSH_MSG_CHANNEL_EXTENDED_DATA 1033 [ssh-connection 1] DEBUG com.sshtools.j2ssh.transport.Service - Routing SSH_MSG_CHANNEL_EXTENDED_DATA 1033 [ssh-connection 1] DEBUG com.sshtools.j2ssh.transport.Service - Finished processing SSH_MSG_CHANNEL_EXTENDED_DATA 1075 [Transport protocol 1] INFO com.sshtools.j2ssh.transport.TransportProtocolCommon - Received SSH_MSG_CHANNEL_FAILURE 1075 [main] INFO com.sshtools.j2ssh.connection.ConnectionProtocol - Channel request failed</p> </blockquote> <p>Why is this happening ?</p>