错误
com.jcraft.jsch.JSchException: java.net.ConnectException: Connection refused: connect
CODE
session = jsch.getSession(user, host, 22); session.setPassword(password); session.setConfig("StrictHostKeyChecking", "no"); session.setConfig("PreferredAuthentications", "publickey,keyboard-interactive,password"); session.connect(); Channel channel = session.openChannel("exec"); ((ChannelExec) channel).setCommand(command_to_execute); channel.setInputStream(null); ((ChannelExec) channel).setErrStream(System.err); InputStream in = channel.getInputStream(); channel.connect(); BufferedReader reader = new BufferedReader(new InputStreamReader(in)); String line; int index = 0; channel.disconnect(); session.disconnect();