We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
try { sshClient = new SSHClient(); sshClient.addHostKeyVerifier(new PromiscuousVerifier()); sshClient.connect(host, port); // 连接到远程主机 sshClient.authPassword(username, password); // 使用密码进行身份验证 sshClient.setTimeout(timeout); sshClient.setConnectTimeout(timeout); } catch (IOException e) { throw new RuntimeException(e); }
try { Session.Command cmd = session.exec(cmdStr); // 获取标准输出 String output = IOUtils.readFully(cmd.getInputStream()).toString(); log.debug("execute command output: {}", output); // 获取错误输出 String errorOutput = IOUtils.readFully(cmd.getErrorStream()).toString(); if (errorOutput != null && !errorOutput.isEmpty()) { log.debug("execute command error output: {}", output); throw new CommandExecuteException(errorOutput); } cmd.join(this.timeout, TimeUnit.SECONDS); session.close(); return output; } catch (IOException e) { throw new CommandExecuteException(e.getMessage()); }
How to stop executing commands that take too long???
sshClient.setTimeout(timeout); sshClient.setConnectTimeout(timeout); cmd.join(this.timeout, TimeUnit.SECONDS);
None of them have taken effect
The text was updated successfully, but these errors were encountered:
No branches or pull requests
How to stop executing commands that take too long???
None of them have taken effect
The text was updated successfully, but these errors were encountered: