Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.BufferedReader;
- import java.io.IOException;
- import java.io.InputStreamReader;
- import java.util.Properties;
- import com.jcraft.jsch.Channel;
- import com.jcraft.jsch.ChannelExec;
- import com.jcraft.jsch.JSch;
- import com.jcraft.jsch.JSchException;
- import com.jcraft.jsch.Session;
- try {
- JSch js = new JSch();
- Session s = js.getSession("root", "164.132.47.61", 22);
- s.setPassword("29f3d178024866bfe34ba118473e3394964aa3fe3c4bc216599400c892dff89e");
- Properties config = new Properties();
- config.put("StrictHostKeyChecking", "no");
- s.setConfig(config);
- s.connect();
- Channel c = s.openChannel("exec");
- ChannelExec ce = (ChannelExec) c;
- ce.setCommand("iptables"); //aggiungi qua il comando
- ce.setErrStream(System.err);
- ce.connect();
- BufferedReader reader = new BufferedReader(new InputStreamReader(ce.getInputStream()));
- String line;
- while ((line = reader.readLine()) != null) {
- plugin.console.sendMessage(line);
- }
- ce.disconnect();
- s.disconnect();
- plugin.console.sendMessage("Exit code: " + ce.getExitStatus());
- } catch (IOException e) {
- e.printStackTrace();
- } catch (JSchException e) {
- e.printStackTrace();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement