到目前为止,我试过这个:
ExpectJ expectinator = new ExpectJ(20);
try {
Spawn shell = expectinator.spawn(ip, 22, userName, userPasswd);
shell.send(stopFirewall);
shell.send("exit\n");
shell.expectClose();
} catch (IOException | TimeoutException | ExpectJException e) {
String errMsg = "Failed to disable firewall of " + ip + " machine";
}
但是我收到以下错误消息:
**java.io.IOException: Unable to establish SSH session/channel**
**Connection refused: connect**