Examples of openChannel()


Examples of com.jcraft.jsch.Session.openChannel()

      UserInfo ui = new SshUser();
      session.setUserInfo(ui);
      session.connect();

      String command = "scp -p -t  " + targetFileName;
      Channel channel = session.openChannel("exec");
      ((ChannelExec) channel).setCommand(command);

      // get I/O streams for remote scp
      OutputStream out = channel.getOutputStream();
      InputStream in = channel.getInputStream();
View Full Code Here

Examples of com.jcraft.jsch.Session.openChannel()

      Session session = jsch.getSession("root", dnsName, 22);
      UserInfo ui = new SshUser();
      session.setUserInfo(ui);
      session.connect();

      Channel channel = session.openChannel("exec");

      ((ChannelExec) channel).setCommand(command);
      ((ChannelExec) channel).setErrStream(System.out);
      InputStream in = channel.getInputStream();
      channel.connect();
View Full Code Here

Examples of com.jcraft.jsch.Session.openChannel()

      Session session = getSession(pathOrUri);
        String host = session.getHost();
        ChannelSftp channel = SshCache.getInstance().getChannelSftp(session);
        if(channel == null) {
            try {
                channel = (ChannelSftp) session.openChannel("sftp");
                channel.connect();
                Message.verbose(":: SFTP :: connected to "+host+"!");
                SshCache.getInstance().attachChannelSftp(session,channel);
            } catch (JSchException e) {
                IOException ex = new IOException(e.getMessage());
View Full Code Here

Examples of com.jcraft.jsch.Session.openChannel()

    Session session =  jsch.getSession("root", "192.168.1.1", 22);
    session.setUserInfo(ui);
    session.connect();
    String command = "iptables -L INPUT -nv --line-numbers";
    try {
        Channel channel=session.openChannel("exec");
        ((ChannelExec)channel).setCommand(command);
        channel.setInputStream(null);
        ((ChannelExec)channel).setErrStream(System.err);

        BufferedReader bReader = new BufferedReader(new InputStreamReader(channel.getInputStream()));
View Full Code Here

Examples of com.jcraft.jsch.Session.openChannel()

  public static String exec(SecureContext pContext, String pCommand)
      throws JSchException, IOException {
    Session session = pContext.createSession();
    session.connect();
    String result = "";
    Channel channel = session.openChannel("exec");
    ((ChannelExec) channel).setCommand(pCommand);
    final ByteArrayOutputStream myOut = new ByteArrayOutputStream();
    ((ChannelExec) channel).setErrStream(new PrintStream(myOut));

    InputStream in = null;
View Full Code Here

Examples of com.jcraft.jsch.Session.openChannel()

        public synchronized SftpChannel getSftpChannel() throws IOException {
            Session session = getSession();

            ChannelSftp sftpChannel;
            try {
                sftpChannel = (ChannelSftp) session.openChannel("sftp");

                channelCount++;
                sftpChannel.connect();
            } catch (JSchException e) {
                // TODO: Close session if it's failed??
View Full Code Here

Examples of com.jcraft.jsch.Session.openChannel()

                throws IOException {
            Session session = getSession();

            ChannelDirectTCPIP directChannel;
            try {
                directChannel = (ChannelDirectTCPIP) session.openChannel("direct-tcpip");

                directChannel.setHost(InetAddresses.toAddrString(remote.getAddress()));
                directChannel.setPort(remote.getPort());

                directChannel.setOrgIPAddress(InetAddresses.toAddrString(local.getAddress()));
View Full Code Here

Examples of com.jcraft.jsch.Session.openChannel()

        public int execute(String command, OutputStream stdout, OutputStream stderr) throws IOException {
            Session session = getSession();

            ChannelExec channel;
            try {
                channel = (ChannelExec) session.openChannel("exec");

                channel.setInputStream(null);
                channel.setOutputStream(stdout);
                channel.setErrStream(stderr);
View Full Code Here

Examples of com.jcraft.jsch.Session.openChannel()

    final Session session = getSession();

    session.connect();

    final ChannelExec channel = (ChannelExec) session.openChannel("exec");

    channel.setCommand(command);

    channel.connect();
View Full Code Here

Examples of com.jcraft.jsch.Session.openChannel()

    final Session session = getSession();

    session.connect();

    final ChannelSftp channel = (ChannelSftp) session.openChannel("sftp");

    channel.connect();

    //
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.