pyftpdlib under docker and docker-compose

410 views
Skip to first unread message

Sam Deleu

unread,
Nov 7, 2017, 5:58:12 AM11/7/17
to Python FTP server library - Discussion group
Hi,

I am using the pytftpdlib 1.5.3 and like it a lot.
But I have a problem when starting it in a docker image.

When i start it locally on my mac and connect via an ftp-client, i get:

ftp> ls

229 Entering extended passive mode (|||64678|).

150 File status okay. About to open data connection.

226 Transfer complete. SAMSAM

ftp> 



When I use docker to start the server and do a ls or dir i get the following:

Using binary mode to transfer files.

ftp> ls

229 Entering extended passive mode (|||59539|).

ftp: Can't connect to `::1': Connection refused

500 Command "LPRT" not understood.

150 File status okay. About to open data connection.



Furthermore the entire server is blocking somehow.

Does anybody has an idea what can be the reason?

Thanks in advance

Sam



Giampaolo Rodola'

unread,
Nov 7, 2017, 8:06:19 AM11/7/17
to pyft...@googlegroups.com
Please run the server in debug mode and paste the logs:

--
You received this message because you are subscribed to the "Python FTP server library" project group:
http://code.google.com/p/pyftpdlib/
To post to this group, send email to pyft...@googlegroups.com
To unsubscribe from this group, send email to pyftpdlib-unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/pyftpdlib
---
You received this message because you are subscribed to the Google Groups "Python FTP server library - Discussion group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyftpdlib+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

Sam Deleu

unread,
Nov 7, 2017, 10:41:51 AM11/7/17
to Python FTP server library - Discussion group
Hi again,

Thanks for your quick reply.
I have been digging further. First i realised that i don't have the initial logging at startup.
So i found that the function
      def _log_start(self 
was never executed. That is because i use the serve_forever with  blocking=False and a small timeout.  
The FTP Server has to run in the same thread as a small http server to provide a rest interface.
By doing some small logic so that the routine is executed once i got the following:
2017-11-07 16:30:19.482 - ( pyftpdlib) [    INFO]    servers ([8720])-(MainThread) >>> starting FTP server on 0.0.0.0:2121, pid=8720 <<<
2017-11-07 16:30:19.483 - ( pyftpdlib) [    INFO]    servers ([8720])-(MainThread) concurrency model: async
2017-11-07 16:30:19.483 - ( pyftpdlib) [    INFO]    servers ([8720])-(MainThread) masquerade (NAT) address: None
2017-11-07 16:30:19.483 - ( pyftpdlib) [    INFO]    servers ([8720])-(MainThread) passive ports: None
2017-11-07 16:30:19.483 - ( pyftpdlib) [   DEBUG]    servers ([8720])-(MainThread) poller: 'pyftpdlib.ioloop.Kqueue'
2017-11-07 16:30:19.483 - ( pyftpdlib) [   DEBUG]    servers ([8720])-(MainThread) authorizer: 'app.ftpauthorizer.M4EAuthorizer'
2017-11-07 16:30:19.483 - ( pyftpdlib) [   DEBUG]    servers ([8720])-(MainThread) use sendfile(2): True
2017-11-07 16:30:19.483 - ( pyftpdlib) [   DEBUG]    servers ([8720])-(MainThread) handler: 'app.ftpserver.type'
2017-11-07 16:30:19.484 - ( pyftpdlib) [   DEBUG]    servers ([8720])-(MainThread) max connections: 512
2017-11-07 16:30:19.484 - ( pyftpdlib) [   DEBUG]    servers ([8720])-(MainThread) max connections per ip: unlimited
2017-11-07 16:30:19.484 - ( pyftpdlib) [   DEBUG]    servers ([8720])-(MainThread) timeout: 300
2017-11-07 16:30:19.484 - ( pyftpdlib) [   DEBUG]    servers ([8720])-(MainThread) banner: 'pyftpdlib 1.5.4 ready.'
2017-11-07 16:30:19.484 - ( pyftpdlib) [   DEBUG]    servers ([8720])-(MainThread) max login attempts: 3

I found a mistake in the passive_ports setting (=range(50000, 5001)), this evaluates to False, so the passivePorts were not used.
I need to to more checks now with a valid setting.

Thank again for your help

Sam 

Giampaolo Rodola'

unread,
Nov 7, 2017, 10:58:12 AM11/7/17
to pyft...@googlegroups.com
I mean post the logs (commands and responses between client and server) when the problem occurs, which according to your previous message is between PASV and EPRT commands.

--
You received this message because you are subscribed to the "Python FTP server library" project group:
http://code.google.com/p/pyftpdlib/
To post to this group, send email to pyft...@googlegroups.com
To unsubscribe from this group, send email to pyftpdlib-unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/pyftpdlib
---
You received this message because you are subscribed to the Google Groups "Python FTP server library - Discussion group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyftpdlib+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Message has been deleted

Griffin Kelly

unread,
Feb 23, 2018, 6:30:14 PM2/23/18
to Python FTP server library - Discussion group
DId you resolve this? I'm having similar issues. When run on localhost works great, when dockerized, will login, but cannot list the directories. 

 docker run -p 1-25:1-25 -p 10021:10021 ftp



Logs: 

[I 2018-02-23 23:26:40] >>> starting FTP server on 0.0.0.0:21, pid=8 <<<

[I 2018-02-23 23:26:40] concurrency model: async

[I 2018-02-23 23:26:40] masquerade (NAT) address: None

[I 2018-02-23 23:26:40] passive ports: 3000->3010

[D 2018-02-23 23:26:40] poller: 'pyftpdlib.ioloop.Epoll'

[D 2018-02-23 23:26:40] authorizer: 'pyftpdlib.authorizers.DummyAuthorizer'

[D 2018-02-23 23:26:40] use sendfile(2): False

[D 2018-02-23 23:26:40] handler: 'pyftpdlib.handlers.FTPHandler'

[D 2018-02-23 23:26:40] max connections: 512

[D 2018-02-23 23:26:40] max connections per ip: unlimited

[D 2018-02-23 23:26:40] timeout: 300

[D 2018-02-23 23:26:40] banner: 'pyftpdlib 1.5.3 ready.'

[D 2018-02-23 23:26:40] max login attempts: 3

[I 2018-02-23 23:27:43] 172.17.0.1:47416-[] FTP session opened (connect)

[D 2018-02-23 23:27:43] 172.17.0.1:47416-[] -> 220 pyftpdlib 1.5.3 ready.

[D 2018-02-23 23:27:43] 172.17.0.1:47416-[] <- AUTH TLS

[D 2018-02-23 23:27:43] 172.17.0.1:47416-[] -> 500 Command "AUTH" not understood.

[D 2018-02-23 23:27:43] 172.17.0.1:47416-[] <- AUTH SSL

[D 2018-02-23 23:27:43] 172.17.0.1:47416-[] -> 500 Command "AUTH" not understood.

[D 2018-02-23 23:27:43] 172.17.0.1:47416-[] <- USER anonymous

[D 2018-02-23 23:27:43] 172.17.0.1:47416-[] -> 331 Username ok, send password.

[D 2018-02-23 23:27:43] 172.17.0.1:47416-[anonymous] <- PASS ******

[D 2018-02-23 23:27:43] 172.17.0.1:47416-[anonymous] -> 230 Login successful.

[I 2018-02-23 23:27:43] 172.17.0.1:47416-[anonymous] USER 'anonymous' logged in.

[D 2018-02-23 23:27:43] 172.17.0.1:47416-[anonymous] <- SYST

[D 2018-02-23 23:27:43] 172.17.0.1:47416-[anonymous] -> 215 UNIX Type: L8

[D 2018-02-23 23:27:43] 172.17.0.1:47416-[anonymous] <- FEAT

[D 2018-02-23 23:27:43] 172.17.0.1:47416-[anonymous] -> 211 End FEAT.

[D 2018-02-23 23:27:43] 172.17.0.1:47416-[anonymous] <- OPTS UTF8 ON

[D 2018-02-23 23:27:43] 172.17.0.1:47416-[anonymous] -> 501 Invalid argument.

[D 2018-02-23 23:27:43] 172.17.0.1:47416-[anonymous] <- OPTS MLST type;perm;size;modify;unix.mode;unix.uid;unix.gid;

[D 2018-02-23 23:27:43] 172.17.0.1:47416-[anonymous] -> 200 MLST OPTS type;perm;size;modify;unix.mode;unix.uid;unix.gid;

[D 2018-02-23 23:27:43] 172.17.0.1:47416-[anonymous] <- PWD

[D 2018-02-23 23:27:43] 172.17.0.1:47416-[anonymous] -> 257 "/" is the current directory.

[D 2018-02-23 23:27:43] 172.17.0.1:47416-[anonymous] <- TYPE I

[D 2018-02-23 23:27:43] 172.17.0.1:47416-[anonymous] -> 200 Type set to: Binary.

[D 2018-02-23 23:27:43] 172.17.0.1:47416-[anonymous] <- PASV

[D 2018-02-23 23:27:43] 172.17.0.1:47416-[anonymous] -> 227 Entering passive mode (172,17,0,2,11,187).

[D 2018-02-23 23:27:43] 172.17.0.1:47416-[anonymous] <- MLSD

[D 2018-02-23 23:27:43] 172.17.0.1:47416-[anonymous] -> 150 File status okay. About to open data connection.

[D 2018-02-23 23:28:03] [debug] call: close() (<FTPHandler(id=140407470878304, addr='172.17.0.1:47416', user=u'anonymous')>)

[D 2018-02-23 23:28:03] [debug] call: close() (<pyftpdlib.handlers.PassiveDTP listening 172.17.0.2:3003 at 0x7fb3296dc1b8>)

[I 2018-02-23 23:28:03] 172.17.0.1:47416-[anonymous] FTP session closed (disconnect).

[I 2018-02-23 23:28:03] 172.17.0.1:47418-[] FTP session opened (connect)

[D 2018-02-23 23:28:03] 172.17.0.1:47418-[] -> 220 pyftpdlib 1.5.3 ready.

[D 2018-02-23 23:28:03] 172.17.0.1:47418-[] <- AUTH TLS

[D 2018-02-23 23:28:03] 172.17.0.1:47418-[] -> 500 Command "AUTH" not understood.

[D 2018-02-23 23:28:03] 172.17.0.1:47418-[] <- AUTH SSL

[D 2018-02-23 23:28:03] 172.17.0.1:47418-[] -> 500 Command "AUTH" not understood.

[D 2018-02-23 23:28:03] 172.17.0.1:47418-[] <- USER anonymous

[D 2018-02-23 23:28:03] 172.17.0.1:47418-[] -> 331 Username ok, send password.

[D 2018-02-23 23:28:03] 172.17.0.1:47418-[anonymous] <- PASS ******

[D 2018-02-23 23:28:03] 172.17.0.1:47418-[anonymous] -> 230 Login successful.

[I 2018-02-23 23:28:03] 172.17.0.1:47418-[anonymous] USER 'anonymous' logged in.

[D 2018-02-23 23:28:03] 172.17.0.1:47418-[anonymous] <- OPTS UTF8 ON

[D 2018-02-23 23:28:03] 172.17.0.1:47418-[anonymous] -> 501 Invalid argument.

[D 2018-02-23 23:28:03] 172.17.0.1:47418-[anonymous] <- OPTS MLST type;perm;size;modify;unix.mode;unix.uid;unix.gid;

[D 2018-02-23 23:28:03] 172.17.0.1:47418-[anonymous] -> 200 MLST OPTS type;perm;size;modify;unix.mode;unix.uid;unix.gid;

[D 2018-02-23 23:28:03] 172.17.0.1:47418-[anonymous] <- PWD

[D 2018-02-23 23:28:03] 172.17.0.1:47418-[anonymous] -> 257 "/" is the current directory.

[D 2018-02-23 23:28:03] 172.17.0.1:47418-[anonymous] <- TYPE I

[D 2018-02-23 23:28:03] 172.17.0.1:47418-[anonymous] -> 200 Type set to: Binary.

[D 2018-02-23 23:28:03] 172.17.0.1:47418-[anonymous] <- PASV

[D 2018-02-23 23:28:03] 172.17.0.1:47418-[anonymous] -> 227 Entering passive mode (172,17,0,2,11,189).

[D 2018-02-23 23:28:03] 172.17.0.1:47418-[anonymous] <- MLSD

[D 2018-02-23 23:28:03] 172.17.0.1:47418-[anonymous] -> 150 File status okay. About to open data connection.

Reply all
Reply to author
Forward
0 new messages