public static void SSH(String Host,String username,String passwor,String cmd,String cmd1) { byte[] tmp = new byte[1024]; String host =Host; String user =username; String password =passwor; String command = cmd; String ou=null; try { Properties config = new Properties(); config.put("StrictHostKeyChecking", "no"); JSch jsch = new JSch(); // Create a JSch session to connect to the server Session session = jsch.getSession(user, host, 22); session.setPassword(password); session.setConfig(config); // Establish the connection session.connect(); System.out.println("Connected..."); ChannelExec channel = (ChannelExec) session.openChannel("exec"); channel.setCommand(command); channel.setErrStream(System.err); channel.connect(); ...
Comments
Post a Comment