1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
|
#!/usr/bin/env python3
# Copyright (C) 2007 Giampaolo Rodola' <g.rodola@gmail.com>.
# Use of this source code is governed by MIT license that can be
# found in the LICENSE file.
"""
An RFC-4217 asynchronous FTPS server supporting both SSL and TLS.
Requires PyOpenSSL module (https://pypi.org/project/pyOpenSSL).
"""
import os
from pyftpdlib.authorizers import DummyAuthorizer
from pyftpdlib.handlers import TLS_FTPHandler
from pyftpdlib.servers import FTPServer
CERTFILE = os.path.abspath(
os.path.join(os.path.dirname(__file__), "keycert.pem")
)
def main():
authorizer = DummyAuthorizer()
authorizer.add_user('user', '12345', '.', perm='elradfmwMT')
authorizer.add_anonymous('.')
handler = TLS_FTPHandler
handler.certfile = CERTFILE
handler.authorizer = authorizer
# requires SSL for both control and data channel
# handler.tls_control_required = True
# handler.tls_data_required = True
server = FTPServer(('', 2121), handler)
server.serve_forever()
if __name__ == '__main__':
main()
|