Package com.jcraft.jsch

Examples of com.jcraft.jsch.JSch.addIdentity()


        if (isNotEmpty(sftpConfig.getPrivateKeyFile())) {
            LOG.debug("Using private keyfile: " + sftpConfig.getPrivateKeyFile());
            if (isNotEmpty(sftpConfig.getPrivateKeyFilePassphrase())) {
                jsch.addIdentity(sftpConfig.getPrivateKeyFile(), sftpConfig.getPrivateKeyFilePassphrase());
            } else {
                jsch.addIdentity(sftpConfig.getPrivateKeyFile());
            }
        }

        if (isNotEmpty(sftpConfig.getKnownHostsFile())) {
            LOG.debug("Using knownhosts file: " + sftpConfig.getKnownHostsFile());
View Full Code Here


  public static void scp(String keyPath, String sourcePath, String targetHostName, String targetFileName)
          throws IOException {
    try {
      File keyFile = new File(keyPath);
      JSch jsch = new JSch();
      jsch.addIdentity(keyFile.getAbsolutePath());
      Session session = jsch.getSession("root", targetHostName, 22);
      UserInfo ui = new SshUser();
      session.setUserInfo(ui);
      session.connect();
View Full Code Here

  public static boolean sshRemoteCommand(String dnsName, String command, String keyPath) throws IOException {
    try {
      File file = new File(keyPath);
      JSch jsch = new JSch();
      jsch.addIdentity(file.getAbsolutePath());
      Session session = jsch.getSession("root", dnsName, 22);
      UserInfo ui = new SshUser();
      session.setUserInfo(ui);
      session.connect();
View Full Code Here

                if(port != -1)
                    session = jsch.getSession(username,host,port);
                else
                    session = jsch.getSession(username,host);
                if(pemFile != null) {
                    jsch.addIdentity(pemFile.getAbsolutePath(), pemPassword);
                }
                session.setUserInfo(new cfUserInfo(host,username,userPassword,pemFile,pemPassword,passFile));
                session.connect();
                Message.verbose(":: SSH :: connected to "+host+"!");
                setSession(username, host, port, session);
View Full Code Here

    File file = new File(fileName);
    FileInputStream fis = new FileInputStream(file);
   
    UserInfoImpl ui = new UserInfoImpl(this.prop);
                    
    jsch.addIdentity("C:\\cygwin\\home\\Stelk\\.ssh\\id_rsa");
    Session session =  jsch.getSession("root", "192.168.1.1", 22);
    session.setUserInfo(ui);
    session.connect();
    String command = "iptables -L INPUT -nv --line-numbers";
    try {
View Full Code Here

         session.setTimeout(sessionTimeout);
      if (loginCredentials.getPrivateKey() == null) {
         session.setPassword(loginCredentials.getPassword());
      } else if (loginCredentials.hasUnencryptedPrivateKey()) {
         byte[] privateKey = loginCredentials.getPrivateKey().getBytes();
         jsch.addIdentity(loginCredentials.getUser(), privateKey, null, emptyPassPhrase);
      } else if (agentConnector.isPresent()) {
         JSch.setConfig("PreferredAuthentications", "publickey");
         jsch.setIdentityRepository(new RemoteIdentityRepository(agentConnector.get()));
      }
      java.util.Properties config = new java.util.Properties();
View Full Code Here

  }

  public Session createSession() throws JSchException {
    JSch jsch = new JSch();
    if (getPrivateKeyFile() != null) {
      jsch.addIdentity(getPrivateKeyFile().getAbsolutePath());
    }
    ParsConf pars = new ParsConf();
    pars.generatePars();
    Document doc = pars.getDoc();
    int port = Integer.parseInt(doc.getElementsByTagName("port").item(0).getTextContent());
View Full Code Here

  private Session getSession() throws Exception {

    final JSch jsch = new JSch();

    jsch.addIdentity(keyFile.getAbsolutePath());

    final Session session = jsch.getSession(user, host, port);

    session.setConfig("StrictHostKeyChecking", "no");
View Full Code Here

        SftpConfiguration sftpConfig = (SftpConfiguration) configuration;

        if (isNotEmpty(sftpConfig.getPrivateKeyFile())) {
            LOG.debug("Using private keyfile: " + sftpConfig.getPrivateKeyFile());
            if (isNotEmpty(sftpConfig.getPrivateKeyFilePassphrase())) {
                jsch.addIdentity(sftpConfig.getPrivateKeyFile(), sftpConfig.getPrivateKeyFilePassphrase());
            } else {
                jsch.addIdentity(sftpConfig.getPrivateKeyFile());
            }
        }
View Full Code Here

        if (isNotEmpty(sftpConfig.getPrivateKeyFile())) {
            LOG.debug("Using private keyfile: " + sftpConfig.getPrivateKeyFile());
            if (isNotEmpty(sftpConfig.getPrivateKeyFilePassphrase())) {
                jsch.addIdentity(sftpConfig.getPrivateKeyFile(), sftpConfig.getPrivateKeyFilePassphrase());
            } else {
                jsch.addIdentity(sftpConfig.getPrivateKeyFile());
            }
        }

        if (isNotEmpty(sftpConfig.getKnownHostsFile())) {
            LOG.debug("Using knownhosts file: " + sftpConfig.getKnownHostsFile());
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.