Package com.trilead.ssh2

Examples of com.trilead.ssh2.Connection.openSession()


      if (isAuthenticated == false)
        throw new IOException("Authentication failed.");

      /* Create a session */

      Session sess = conn.openSession();

      sess.execCommand("uname -a && date && uptime && who");

      System.out.println("Here is some information about the remote host:");

View Full Code Here


      if (isAuthenticated == false)
        throw new IOException("Authentication failed.");

      /* Create a session */

      Session sess = conn.openSession();

      sess.execCommand("echo \"Huge amounts of text on STDOUT\"; echo \"Huge amounts of text on STDERR\" >&2");

      /*
       * Advanced:
 
View Full Code Here

         *
         * AUTHENTICATION OK. DO SOMETHING.
         *
         */

        Session sess = conn.openSession();

        int x_width = 90;
        int y_width = 30;

        sess.requestPTY("dumb", x_width, y_width, 0, 0, null);
View Full Code Here

      if (isAuthenticated == false)
        throw new IOException("Authentication failed.");

      /* Create a session */

      Session sess = conn.openSession();

      sess.execCommand("uname -a && date && uptime && who");

      System.out.println("Here is some information about the remote host:");

View Full Code Here

      if (isAuthenticated == false)
        throw new IOException("Authentication failed.");

      /* Create a session */

      Session sess = conn.openSession();

      sess.execCommand("echo \"Text on STDOUT\"; echo \"Text on STDERR\" >&2");

      InputStream stdout = new StreamGobbler(sess.getStdout());
      InputStream stderr = new StreamGobbler(sess.getStderr());
View Full Code Here

      if (isAuthenticated == false)
        throw new IOException("Authentication failed.");

      /* Create a session */

      Session sess = conn.openSession();

      sess.execCommand("uname -a && date && uptime && who");

      InputStream stdout = new StreamGobbler(sess.getStdout());
      BufferedReader br = new BufferedReader(new InputStreamReader(stdout));
View Full Code Here

      if (isAuthenticated == false)
        throw new IOException("Authentication failed.");

      /* Create a session */

      Session sess = conn.openSession();

      sess.execCommand("uname -a && date && uptime && who");

      InputStream stdout = new StreamGobbler(sess.getStdout());

View Full Code Here

            boolean isAuthenticated = conn.authenticateWithPassword(this.user, this.password);
            if (isAuthenticated == false) {
                result.append("ERROR: Authentication Failed !");
            }

            Session session = conn.openSession();

            session.execCommand(cmd);
            BufferedReader read =
                    new BufferedReader(new InputStreamReader(new StreamGobbler(session.getStdout()), "GBK"));
            String line = "";
View Full Code Here

            if (isAuthenticated == false) {
              s_logger.info("Authentication failed for root with password");
              return false;
            }
           
            Session sess = conn.openSession();
            s_logger.info("Executing : " + commandElement.getTextContent());
            sess.execCommand(commandElement.getTextContent());
            Thread.sleep(60000);
            sess.close();
            conn.close();
View Full Code Here

            s_logger.info("Authentication failed for root with password");
            return false;
          }
         
          String restartCommand = "service cloud-management restart; service cloud-usage restart";
          Session sess = conn.openSession();
          s_logger.info("Executing : " + restartCommand);
          sess.execCommand(restartCommand);
          Thread.sleep(120000);
          sess.close();
          conn.close();
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.