Skip to content

Python: start simple FTP server

Start FTP server in current directory, account user, password user. Start as root for use 21 port.

#!/usr/bin/env python3
from pyftpdlib.authorizers import DummyAuthorizer
from pyftpdlib.handlers import FTPHandler
from pyftpdlib.servers import FTPServer

authorizer = DummyAuthorizer()
authorizer.add_user("user", "user", "./", perm="elradfmwMT")
authorizer.add_anonymous("./")

handler = FTPHandler
handler.authorizer = authorizer

server = FTPServer(("0.0.0.0", 21), handler)
server.serve_forever()