Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker container PASV not able to connect #140

Open
unknownguy opened this issue Aug 3, 2022 · 4 comments
Open

Docker container PASV not able to connect #140

unknownguy opened this issue Aug 3, 2022 · 4 comments

Comments

@unknownguy
Copy link

I am having troubles connecting to local docker container using PASV. However, this works fine using EPSV. Outside of the docker container everything works great!

I will add my config info and logs from both PASV and EPSV.

Current settings:

services
      .Configure<SimplePasvOptions>(
      opt =>
      {
          opt.PasvMinPort = 49152;
          opt.PasvMaxPort = 49153;
      })
      .Configure<FtpServerOptions>(opt =>
      {
          //opt.ServerAddress = "*";
          opt.Port = 21;
      });

Container active ports are:
21, 80, 443, 49152, 49153

They are active on both container and host ports.

PASV log:

info: FubarDev.FtpServer.FtpConnection[0]
      Connected from 172.17.0.1:42734
dbug: FubarDev.FtpServer.ServerCommandHandlers.SendResponseServerCommandHandler[0]
      220 FTP Server Ready
dbug: FubarDev.FtpServer.FtpConnection[0]
      USER XXX
dbug: FubarDev.FtpServer.ServerCommandHandlers.SendResponseServerCommandHandler[0]
      331 User XXX logged in, needs password
dbug: FubarDev.FtpServer.FtpConnection[0]
      PASS **************** (password omitted)
dbug: FubarDev.FtpServer.ServerCommandHandlers.SendResponseServerCommandHandler[0]
      230 Password ok, FTP server ready
dbug: FubarDev.FtpServer.FtpConnection[0]
      TYPE A
dbug: FubarDev.FtpServer.ServerCommandHandlers.SendResponseServerCommandHandler[0]
      200 ASCII transfer mode active.
dbug: FubarDev.FtpServer.FtpConnection[0]
      MODE S
dbug: FubarDev.FtpServer.ServerCommandHandlers.SendResponseServerCommandHandler[0]
      200 Mode set to Stream.
dbug: FubarDev.FtpServer.FtpConnection[0]
      STRU F
dbug: FubarDev.FtpServer.ServerCommandHandlers.SendResponseServerCommandHandler[0]
      200 Structure set to File.
dbug: FubarDev.FtpServer.FtpConnection[0]
      CWD /
dbug: FubarDev.FtpServer.ServerCommandHandlers.SendResponseServerCommandHandler[0]
      250 Successful (/)
dbug: FubarDev.FtpServer.FtpConnection[0]
      CWD /
dbug: FubarDev.FtpServer.ServerCommandHandlers.SendResponseServerCommandHandler[0]
      250 Successful (/)
dbug: FubarDev.FtpServer.FtpConnection[0]
      PASV 
dbug: FubarDev.FtpServer.ServerCommandHandlers.SendResponseServerCommandHandler[0]
      227 Entering Passive Mode (172,17,0,2,192,0).
dbug: FubarDev.FtpServer.FtpConnection[0]
      LIST 
dbug: FubarDev.FtpServer.ServerCommandHandlers.SendResponseServerCommandHandler[0]
      150 Opening data connection.
warn: FubarDev.FtpServer.ServerCommandHandlers.DataConnectionServerCommandHandler[0]
      Could not open data connection: The operation has timed out.
System.TimeoutException: The operation has timed out.
   at FubarDev.FtpServer.DataConnection.PassiveDataConnectionFeatureFactory.PassiveDataConnectionFeature.GetDataConnectionAsync(TimeSpan timeout, CancellationToken cancellationToken)
   at FubarDev.FtpServer.FtpConnection.OpenDataConnectionAsync(Nullable`1 timeout, CancellationToken cancellationToken)
   at FubarDev.FtpServer.ServerCommandHandlers.DataConnectionServerCommandHandler.ExecuteAsync(DataConnectionServerCommand command, CancellationToken cancellationToken)
dbug: FubarDev.FtpServer.ServerCommandHandlers.SendResponseServerCommandHandler[0]
      425 Could not open data connection
dbug: FubarDev.FtpServer.FtpConnection[0]
      Quit 
dbug: FubarDev.FtpServer.FtpConnection[0]
      Stopped sending responses
dbug: FubarDev.FtpServer.FtpConnection[0]
      Stopped reading commands
warn: FubarDev.FtpServer.Commands.DefaultFtpCommandDispatcher[0]
      Sending the response cancelled: 426 Connection closed; transfer aborted.
info: FubarDev.FtpServer.FtpConnection[0]
      Connection closed

EPSV log:

info: FubarDev.FtpServer.FtpConnection[0]
      Connected from 172.17.0.1:42738
dbug: FubarDev.FtpServer.ServerCommandHandlers.SendResponseServerCommandHandler[0]
      220 FTP Server Ready
dbug: FubarDev.FtpServer.FtpConnection[0]
      AUTH TLS
dbug: FubarDev.FtpServer.ServerCommandHandlers.SendResponseServerCommandHandler[0]
      500 Syntax error, command unrecognized.
dbug: FubarDev.FtpServer.FtpConnection[0]
      AUTH SSL
dbug: FubarDev.FtpServer.ServerCommandHandlers.SendResponseServerCommandHandler[0]
      500 Syntax error, command unrecognized.
dbug: FubarDev.FtpServer.FtpConnection[0]
      USER XXX
dbug: FubarDev.FtpServer.ServerCommandHandlers.SendResponseServerCommandHandler[0]
      331 User XXX logged in, needs password
dbug: FubarDev.FtpServer.FtpConnection[0]
      PASS **************** (password omitted)
dbug: FubarDev.FtpServer.ServerCommandHandlers.SendResponseServerCommandHandler[0]
      230 Password ok, FTP server ready
dbug: FubarDev.FtpServer.FtpConnection[0]
      SYST 
dbug: FubarDev.FtpServer.ServerCommandHandlers.SendResponseServerCommandHandler[0]
      215 UNIX Type: A
dbug: FubarDev.FtpServer.FtpConnection[0]
      FEAT 
dbug: FubarDev.FtpServer.ServerCommandHandlers.SendResponseServerCommandHandler[0]
      211-Extensions supported:
dbug: FubarDev.FtpServer.ServerCommandHandlers.SendResponseServerCommandHandler[0]
       EPRT
dbug: FubarDev.FtpServer.ServerCommandHandlers.SendResponseServerCommandHandler[0]
       EPSV
dbug: FubarDev.FtpServer.ServerCommandHandlers.SendResponseServerCommandHandler[0]
       HOST
dbug: FubarDev.FtpServer.ServerCommandHandlers.SendResponseServerCommandHandler[0]
       LANG en*
dbug: FubarDev.FtpServer.ServerCommandHandlers.SendResponseServerCommandHandler[0]
       MDTM
dbug: FubarDev.FtpServer.ServerCommandHandlers.SendResponseServerCommandHandler[0]
       MFCT
dbug: FubarDev.FtpServer.ServerCommandHandlers.SendResponseServerCommandHandler[0]
       MFF modify;create;
dbug: FubarDev.FtpServer.ServerCommandHandlers.SendResponseServerCommandHandler[0]
       MFMT
dbug: FubarDev.FtpServer.ServerCommandHandlers.SendResponseServerCommandHandler[0]
       MLST type*;size*;perm*;modify*;create*;
dbug: FubarDev.FtpServer.ServerCommandHandlers.SendResponseServerCommandHandler[0]
       REST STREAM
dbug: FubarDev.FtpServer.ServerCommandHandlers.SendResponseServerCommandHandler[0]
       SITE BLST
dbug: FubarDev.FtpServer.ServerCommandHandlers.SendResponseServerCommandHandler[0]
       SIZE
dbug: FubarDev.FtpServer.ServerCommandHandlers.SendResponseServerCommandHandler[0]
       UTF8
dbug: FubarDev.FtpServer.ServerCommandHandlers.SendResponseServerCommandHandler[0]
      211 END
dbug: FubarDev.FtpServer.FtpConnection[0]
      OPTS UTF8 ON
dbug: FubarDev.FtpServer.ServerCommandHandlers.SendResponseServerCommandHandler[0]
      200 Command okay.
dbug: FubarDev.FtpServer.FtpConnection[0]
      CWD /
dbug: FubarDev.FtpServer.ServerCommandHandlers.SendResponseServerCommandHandler[0]
      250 Successful (/)
dbug: FubarDev.FtpServer.FtpConnection[0]
      PWD 
dbug: FubarDev.FtpServer.ServerCommandHandlers.SendResponseServerCommandHandler[0]
      257 "/"
dbug: FubarDev.FtpServer.FtpConnection[0]
      TYPE I
dbug: FubarDev.FtpServer.ServerCommandHandlers.SendResponseServerCommandHandler[0]
      200 Binary transfer mode active.
dbug: FubarDev.FtpServer.FtpConnection[0]
      EPSV 
dbug: FubarDev.FtpServer.ServerCommandHandlers.SendResponseServerCommandHandler[0]
      229 Entering Extended Passive Mode (|||49152|).
dbug: FubarDev.FtpServer.FtpConnection[0]
      MLSD 
dbug: FubarDev.FtpServer.ServerCommandHandlers.SendResponseServerCommandHandler[0]
      150 Opening data connection.
dbug: FubarDev.FtpServer.DataConnection.PassiveDataConnectionFeatureFactory[0]
      Data connection accepted from 172.17.0.1:58222
trce: FubarDev.FtpServer.CommandHandlers.MlstCommandHandler[0]
      perm=el;type=cdir; .
trce: FubarDev.FtpServer.CommandHandlers.MlstCommandHandler[0]
      perm=el;type=dir; fonts
trce: FubarDev.FtpServer.CommandHandlers.MlstCommandHandler[0]
      perm=el;type=dir; images
trce: FubarDev.FtpServer.CommandHandlers.MlstCommandHandler[0]
      perm=el;type=dir; scripts
trce: FubarDev.FtpServer.CommandHandlers.MlstCommandHandler[0]
      perm=el;type=dir; styles
trce: FubarDev.FtpServer.CommandHandlers.MlstCommandHandler[0]
      perm=el;type=dir; templateItems
trce: FubarDev.FtpServer.CommandHandlers.MlstCommandHandler[0]
      perm=el;type=dir; templates
trce: FubarDev.FtpServer.CommandHandlers.MlstCommandHandler[0]
      perm=r;size=0;type=file; FullMasterPage.html
trce: FubarDev.FtpServer.CommandHandlers.MlstCommandHandler[0]
      perm=r;size=0;type=file; settings.json
dbug: FubarDev.FtpServer.ServerCommandHandlers.SendResponseServerCommandHandler[0]
      226 Closing data connection.

Any thoughts?

@fubar-coder
Copy link
Contributor

No idea. It just looks like the client not being able to connect to the passively opened port. This might have a multitude of causes and is difficult to diagnose from a distance.

@unknownguy
Copy link
Author

For what is worth, the docker image is on linux.

@vudzero
Copy link

vudzero commented Feb 11, 2023

I think you must specify opt.ServerAddres to the IP address used by your client to connect to your ftp server. Otherwise the local ip address of the docker container will be sent back to your client, which is not what you want.

@vudzero
Copy link

vudzero commented Feb 12, 2023

I made it work by setting the PublicAddress of the SimplePasvOptions to the ip address of my server

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants