title: How to use apache vfs2 for sftp with public-private-key and without password
body: <p>Currently I am using apache vfs2 to download files from a sftp. For authentication I use user-name and password.</p>
  
  <p>Is there a way to use vfs2 only with public-private-keys and without a password?</p>
  
  <p>I think I have use this function,but how? Set it only to "yes"?</p>
  
  <pre><code>SftpFileSystemConfigBuilder.getInstance().setStrictHostKeyChecking(options, "no");
  </code></pre>
  
  <p>This is my current code (snippet):</p>
  
  <pre><code>private boolean downloadFile(){
  
      StandardFileSystemManager sysManager = new StandardFileSystemManager();
  
      //download der Datei
      try {
          sysManager.init();
  
          FileObject localFile = sysManager.resolveFile(localFilePath);
  
          FileObject remoteFile = sysManager.resolveFile(createConnectionString(host, user, password, fileName, port),createDefaultOptions());
  
          //Selectors.SELECT_FILES --&gt; A FileSelector that selects only the base file/folder.
          localFile.copyFrom(remoteFile, Selectors.SELECT_FILES);
  
  
      } catch (Exception e) {
          logger.error("Downloading file failed: " + e.toString());
          return false;
      }finally{
          sysManager.close();
      }
      return true;
  }
  </code></pre>
  
  <p>and</p>
  
  <pre><code>private FileSystemOptions createDefaultOptions() throws FileSystemException{
  
      //create options for sftp
      FileSystemOptions options = new FileSystemOptions();
      //ssh key
      SftpFileSystemConfigBuilder.getInstance().setStrictHostKeyChecking(options, "no");
      //set root directory to user home
      SftpFileSystemConfigBuilder.getInstance().setUserDirIsRoot(options, true);
      //timeout
      SftpFileSystemConfigBuilder.getInstance().setTimeout(options, timeout);
  
      return options;
  }
  </code></pre>