hierynomus / sshj

ssh, scp and sftp for java

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

IOUtils.readFully(cmd.getInputStream()) blocks promgram continue to execute

carlwang87 opened this issue · comments

Currently, Use Copssh(Copssh_5.0.0_Free) as ssh server, Copssh only configs allow linux shell. Copssh is installed on windows 10.
image

Code:

        final SSHClient ssh= getSshClient(hostname, port, username, password);
        String result = StringUtils.EMPTY;
        try {
            Session session = ssh.startSession();
            session.allocateDefaultPTY();  
            try {
                Session.Command cmd = session.exec("ls");
                result = IOUtils.readFully(cmd.getInputStream()).toString();
                Integer exitStatus = cmd.getExitStatus();
            } finally {
                session.close();
            }

when debug to result = IOUtils.readFully(cmd.getInputStream()).toString();, the program seems to be block by this line code, no error, no exception.

But when change the Copssh to linux shell and Sftp, it works well.
image

Have anyone encountered this issue?

  1. linux shell and Sftp
    log in Copssh server:
2023.05.27 04:37:09 -  Starting session: command for user from 192.168.1.1 port 14390
  1. linux shell
    log in Copssh server:
2023.05.27 04:35:30 -  Starting session: forced-command (config) '/bin/bash --login -i' for user from 192.168.1.1 port 14118

Why the logs is different?

I think you would better ask in the CopSSH forum/issuetracker/whatever... This is not an sshj problem.