Help, I cannot figure out how to set starting folder of SFTP server. Specifically, I have a web service that is able to transfer files to a SFTP server and I want to use Mina/HTTPD to host a temporary server just for unit test purpose. So, therfore I want the FTP server to host files in my project root, and not show files outside of my project root.
For example, this doesn't work for me. I get an error: sshd.setFileSystemFactory(new VirtualFileSystemFactory(Paths.get("src/test/resources"))); And the error I get when trying to connect is: 20: Invalid filename at com.jcraft.jsch.ChannelSftp.throwStatusError(ChannelSftp.java:2873) at com.jcraft.jsch.ChannelSftp._realpath(ChannelSftp.java:2367) at com.jcraft.jsch.ChannelSftp.getHome(ChannelSftp.java:2437) Note: If I don't set the VirtualFileSystemFactory at all, then I can ftp files to my server with no error but the server root is my entire file system, which is NOT desirable. One thing I tried was this, which explains the desired behavior I want, but it I get a compile error (Error:(97, 13) java: method does not override or implement a method from a supertype) : sshd.setFileSystemFactory(new VirtualFileSystemFactory() { @Override protected Path computeRootDir(Session session) throws IOException { return Paths.get("."); } }); My Maven deps are: <dependency> <groupId>org.apache.sshd</groupId> <artifactId>apache-sshd</artifactId> <version>1.7.0</version> <type>pom</type> </dependency> <dependency> <groupId>com.jcraft</groupId> <artifactId>jsch</artifactId> <version>0.1.54</version> </dependency> My basic setup is: sshd = SshServer.setUpDefaultServer(); sshd.setPort(port); sshd.setKeyPairProvider(new SimpleGeneratorHostKeyProvider(Paths.get(PUBLIC_CERT_FILE))); sshd.setSubsystemFactories(Arrays.asList(new SftpSubsystemFactory())); sshd.setCommandFactory(new ScpCommandFactory()); sshd.setPasswordAuthenticator(new LenientPasswordAuthenticator()); sshd.setPublickeyAuthenticator(new LenientPublicKeyAuthenticator()); I also posted my question here: https://stackoverflow.com/questions/50302137/apache-mina-cannot-set-starting-folder-of-sftp-server -- Sent from: http://apache-mina.10907.n7.nabble.com/Apache-MINA-User-Forum-f31345.html