Hi Stefan,

I haven't worked with this for a while now, but I can set up an environment to 
test this one of these days.

In the code you are using "ftp://"; as virtual file system but in the logs I see 
"sftp://";.

So it was working when your client was using "ftp://"; and your VFS was using 
"ftp://"; too? And now you want your VFS to be "sftp://";?
Have you tried with "ftps://" for the VFS? As sftp goes over SSH a different 
VFS provider is used.

As for the approach, I am not 100% sure but I don't think you have to call the 
createFileSystemView method, that should be done automatically; this part might 
be superfluous:

BaseUser vfsUser = new BaseUser();
vfsUser.setName(ftpUserHetzner);
vfsUser.setPassword(ftpPwdHetzner);
vfsUser.setHomeDirectory("/");

vfsFileSystemFactory.createFileSystemView(vfsUser);

Cheers,

Frank





________________________________
From: Stefan Ziegler <stefan.ziegler...@gmail.com>
Sent: Sunday, November 1, 2020 8:20 PM
To: ftpserver-users@mina.apache.org <ftpserver-users@mina.apache.org>
Subject: Problems with sftp and vfs

Hi

I'm setting up a plain ftp server in front of another ftp server as virtual
file system. This works great since the ftp server used in the virtual file
system does not allow anonymous logins. Switching from plain ftp to ftps in
the virtual file systems ftp server I'm not able to download files anymore.
It still shows the directories but when trying to download a file it seems
like it stalls somehow.

According to the logs it seems that it tries to download as "anonymous"
user and not the user from the virtual file system ftp server (but I can
misinterpret this).

Has anyone an idea or some hints? Do I mess up something in my code (with
the users)? Thanks for any help. See code and logs below.

best regards
Stefan

PropertiesUserManagerFactory userManagerFactory = new
PropertiesUserManagerFactory();
UserManager userManager = userManagerFactory.createUserManager();
BaseUser user = new BaseUser();
user.setName("anonymous");
userManager.save(user);

ListenerFactory listenerFactory = new ListenerFactory();
listenerFactory.setPort(2221);

ConnectionConfigFactory connectionConfigFactory = new
ConnectionConfigFactory();
connectionConfigFactory.setAnonymousLoginEnabled(true);
connectionConfigFactory.setMaxLogins(10);
connectionConfigFactory.setMaxThreads(10);

FtpServerFactory factory = new FtpServerFactory();
factory.setConnectionConfig(connectionConfigFactory.createConnectionConfig());
factory.setUserManager(userManager);
factory.addListener("default", listenerFactory.createListener());

VfsFileSystemFactory vfsFileSystemFactory = new VfsFileSystemFactory();
VfsAuthenticator vfsAuthentificator = new VfsAuthenticator();
vfsAuthentificator.setVfsRoot("ftp://
"+ftpUserHetzner+":"+ftpPwdHetzner+"@"+ftpServerHetzner);
vfsAuthentificator.setVfsType("virtual");

vfsFileSystemFactory.setAuthenticator(vfsAuthentificator);

BaseUser vfsUser = new BaseUser();
vfsUser.setName(ftpUserHetzner);
vfsUser.setPassword(ftpPwdHetzner);
vfsUser.setHomeDirectory("/");

vfsFileSystemFactory.createFileSystemView(vfsUser);
factory.setFileSystem(vfsFileSystemFactory);

FtpServer server = factory.createServer();
server.start();

2020-11-01 19:50:31.043  INFO 117121 --- [ NioProcessor-4]
o.a.f.listener.nio.FtpLoggingFilter      : CREATED
2020-11-01 19:50:31.045  INFO 117121 --- [pool-3-thread-1]
o.a.f.listener.nio.FtpLoggingFilter      : OPENED
2020-11-01 19:50:31.047  INFO 117121 --- [pool-3-thread-2]
o.a.f.listener.nio.FtpLoggingFilter      : SENT: 220 Service ready for new
user.

2020-11-01 19:50:31.060  INFO 117121 --- [pool-3-thread-1]
o.a.f.listener.nio.FtpLoggingFilter      : RECEIVED: USER anonymous
2020-11-01 19:50:31.061 DEBUG 117121 --- [pool-3-thread-1]
org.apache.ftpserver.command.impl.USER   : Currently 1 out of 10 anonymous
users logged in
2020-11-01 19:50:31.061 DEBUG 117121 --- [pool-3-thread-1]
org.apache.ftpserver.command.impl.USER   : Currently 1 out of 5 users
logged in
2020-11-01 19:50:31.063  INFO 117121 --- [pool-3-thread-2]
o.a.f.listener.nio.FtpLoggingFilter      : SENT: 331 Guest login okay, send
your complete e-mail address as password.

2020-11-01 19:50:31.064  INFO 117121 --- [pool-3-thread-2]
o.a.f.listener.nio.FtpLoggingFilter      : RECEIVED: PASS *****
2020-11-01 19:50:31.064 DEBUG 117121 --- [pool-3-thread-2]
org.apache.ftpserver.command.impl.PASS   : Currently 1 out of 10 anonymous
users logged in
2020-11-01 19:50:31.064 DEBUG 117121 --- [pool-3-thread-2]
org.apache.ftpserver.command.impl.PASS   : Currently 1 out of 5 users
logged in
2020-11-01 19:50:31.066 DEBUG 117121 --- [pool-3-thread-2]
o.a.c.vfs2.cache.SoftRefFilesCache       : putFile: sftp://u000000:***@
u000000.your-storagebox.de/
2020-11-01 19:50:31.089  INFO 117121 --- [pool-3-thread-2]
o.v.f.filesystem.VfsAuthenticator        : Authenticated user anonymous
based on filesystem org.apache.commons.vfs2.impl.VirtualFileSystem@53de3b94
2020-11-01 19:50:31.090  INFO 117121 --- [pool-3-thread-2]
org.apache.ftpserver.command.impl.PASS   : Anonymous login success -
anonym...@example.com
2020-11-01 19:50:31.091  INFO 117121 --- [pool-3-thread-1]
o.a.f.listener.nio.FtpLoggingFilter      : SENT: 230 User logged in,
proceed.

2020-11-01 19:50:31.092  INFO 117121 --- [pool-3-thread-1]
o.a.f.listener.nio.FtpLoggingFilter      : RECEIVED: OPTS UTF8 ON
2020-11-01 19:50:31.093  INFO 117121 --- [pool-3-thread-2]
o.a.f.listener.nio.FtpLoggingFilter      : SENT: 200 Command OPTS okay.

2020-11-01 19:50:31.094  INFO 117121 --- [pool-3-thread-2]
o.a.f.listener.nio.FtpLoggingFilter      : RECEIVED: OPTS MLST
size;modify;type;
2020-11-01 19:50:31.096  INFO 117121 --- [pool-3-thread-1]
o.a.f.listener.nio.FtpLoggingFilter      : SENT: 200 Command OPTS okay.

2020-11-01 19:50:31.098  INFO 117121 --- [pool-3-thread-2]
o.a.f.listener.nio.FtpLoggingFilter      : RECEIVED: CWD
/ch.so.agi.av.dm01avch24lv95d
2020-11-01 19:50:31.099 DEBUG 117121 --- [pool-3-thread-2]
o.a.c.vfs2.cache.SoftRefFilesCache       : putFile: sftp://u000000:***@
u000000.your-storagebox.de/ch.so.agi.av.dm01avch24lv95d
2020-11-01 19:50:31.100 DEBUG 117121 --- [pool-3-thread-2]
o.a.c.vfs2.cache.SoftRefFilesCache       : putFile: sftp://u000000:***@
u000000.your-storagebox.de/ch.so.agi.av.dm01avch24lv95d
2020-11-01 19:50:31.442  INFO 117121 --- [pool-3-thread-1]
o.a.f.listener.nio.FtpLoggingFilter      : SENT: 250 Directory changed to
/ch.so.agi.av.dm01avch24lv95d

2020-11-01 19:50:31.443  INFO 117121 --- [pool-3-thread-1]
o.a.f.listener.nio.FtpLoggingFilter      : RECEIVED: TYPE I
2020-11-01 19:50:31.446  INFO 117121 --- [pool-3-thread-2]
o.a.f.listener.nio.FtpLoggingFilter      : SENT: 200 Command TYPE okay.

2020-11-01 19:50:31.447  INFO 117121 --- [pool-3-thread-2]
o.a.f.listener.nio.FtpLoggingFilter      : RECEIVED: PASV
2020-11-01 19:50:31.450 DEBUG 117121 --- [pool-3-thread-2]
o.a.f.impl.IODataConnectionFactory       : Initiating passive data
connection
2020-11-01 19:50:31.450 DEBUG 117121 --- [pool-3-thread-2]
o.a.f.impl.IODataConnectionFactory       : Opening passive data connection
on address "/127.0.0.1" and port 0
2020-11-01 19:50:31.451 DEBUG 117121 --- [pool-3-thread-2]
o.a.f.impl.IODataConnectionFactory       : Passive data connection created
on address "/127.0.0.1" and port 0
2020-11-01 19:50:31.454  INFO 117121 --- [pool-3-thread-1]
o.a.f.listener.nio.FtpLoggingFilter      : SENT: 227 Entering Passive Mode
(127,0,0,1,163,47)

2020-11-01 19:50:31.456  INFO 117121 --- [pool-3-thread-1]
o.a.f.listener.nio.FtpLoggingFilter      : RECEIVED: RETR 257900.itf.zip
2020-11-01 19:50:31.457 DEBUG 117121 --- [pool-3-thread-1]
o.a.c.vfs2.cache.SoftRefFilesCache       : putFile: sftp://u000000:***@
u000000.your-storagebox.de/ch.so.agi.av.dm01avch24lv95d/257900.itf.zip
2020-11-01 19:50:31.457 DEBUG 117121 --- [pool-3-thread-1]
o.a.c.vfs2.cache.SoftRefFilesCache       : putFile: sftp://u000000:***@
u000000.your-storagebox.de/ch.so.agi.av.dm01avch24lv95d/257900.itf.zip




Reply via email to