Example #1
0
  protected void addKnownHosts() {
    //
    if ((config.sshKnowHostFile == null) || (config.sshKnowHostFile == null)) {
      logger.debug("addUserIDFiles(): No userConfigDir or knownHostFile configured");
      return;
    }
    // Config director is for example" ~/.ssh/
    String configDir = config.userConfigDir;
    String knownHostsFile = config.sshKnowHostFile;

    FSPath configPath;
    try {
      if (configDir != null) {
        configPath = FSUtil.getDefault().resolvePath(configDir);
        FSPath hostsFile = configPath.resolvePath(knownHostsFile);
        if (hostsFile.exists()) {
          jsch.setKnownHosts(hostsFile.getPathname());
        }
      }
    } catch (IOException e) {
      logger.error(
          "addKnownHosts():Failed to read/acces known hosts file:{}/{} => IOException:{}",
          configDir,
          knownHostsFile,
          e);
      return;
    } catch (JSchException e) {
      logger.error(
          "addKnownHosts():Failed to add known hosts file:{}/{} => JSchException:{}",
          configDir,
          knownHostsFile,
          e);
      return;
    }
  }
Example #2
0
 public FSNodeProxyNode(ProxyFactory anyFileProxyFactory, VRL loc) throws ProxyException {
   super(anyFileProxyFactory, loc);
   try {
     file = FSUtil.getDefault().newFSPath(loc.getPath());
   } catch (IOException e) {
     throw new ProxyException(e.getMessage(), e);
   }
   init();
 }
Example #3
0
  protected void addUserIDFiles() {
    //
    if (config.userConfigDir == null) {
      logger.debug("addUserIDFiles(): No userConfigDir configured");
      return;
    }
    // Config director is for example" ~/.ssh/
    String configDir = config.userConfigDir;
    FSPath configPath;

    try {
      configPath = FSUtil.getDefault().resolvePath(configDir);
    } catch (IOException e) {
      logger.error(
          "addUserIDFiles():Failed to read/acces config directory:{} => IOException:{}",
          configDir,
          e);
      return;
    }

    String keys[] = config.privateKeys;
    if ((keys == null) || (keys.length <= 0)) {
      logger.info("addUserIDFiles():No private keys");
      return;
    }

    for (String key : keys) {
      try {
        FSPath keyFile = configPath.resolvePath(key);
        if (keyFile.exists()) {
          logger.info("addUserIDFiles(): adding existing identity:{}\n", keyFile);
          jsch.addIdentity(keyFile.getPathname());
        } else {
          logger.info("addUserIDFiles(): ignoring missing identity file:{}\n", keyFile);
        }
      } catch (IOException e) {
        logger.error("Got IOException accessing file:{}/{} => IOException:{}", configPath, key, e);
      } catch (JSchException e) {
        logger.error("Got JSchException adding file:{}/{} => JSchException:{}", configPath, key, e);
      }
    }
  }