How to create a FTP server with ftplib in python

Python has a one liner from which you can create a FTP server using ftplib.

First things first, let’s install the required dependency:

~/$ pip3 install pyftpdlib
Collecting pyftpdlib
Downloading pyftpdlib-1.5.6.tar.gz (188 kB)
|████████████████████████████████| 188 kB 6.4 MB/s
Building wheels for collected packages: pyftpdlib
Building wheel for pyftpdlib ( ... done
Created wheel for pyftpdlib: filename=pyftpdlib-1.5.6-py3-none-any.whl size=125586 sha256=ef64dcea9ebb19497a7f9d91f8b084a321c3ef909b0f5e3470f2ec9ccd66b958
Stored in directory: /home/mickael/.cache/pip/wheels/54/9f/5f/50eae5deee54c11cd059c5bda2ebd7dcd461d81b5c89f50f75
Successfully built pyftpdlib
Installing collected packages: pyftpdlib
Successfully installed pyftpdlib-1.5.6

To serve the current directory via FTP:

~/$ python3 -m pyftpdlib -w --user=username --password=password
[I 2021-12-14 22:48:48] concurrency model: async
[I 2021-12-14 22:48:48] masquerade (NAT) address: None
[I 2021-12-14 22:48:48] passive ports: None
[I 2021-12-14 22:48:48] >>> starting FTP server on, pid=1070306 <<<
[I 2021-12-14 22:49:04][] FTP session opened (connect)
[I 2021-12-14 22:49:08][username] USER 'username' logged in.

To make sure everything is running fine:

~/$ curl --user username:password
drwxr-xr-x 10 mickael mickael 4096 Nov 22 08:29 Documents
drwxr-xr-x 3 mickael mickael 16384 Dec 14 06:35 Downloads

For a FTP client that’s more modern for your users, check our online FTP client:

screenshot of the Filestash webdav client