0

I have a ftp server using pyftpdlib. How would I hide files like the python file running the server?

Here is my code:

import os
from pyftpdlib.authorizers import DummyAuthorizer
from pyftpdlib.handlers import FTPHandler
from pyftpdlib.servers import FTPServer

def main():
    authorizer = DummyAuthorizer()
    authorizer.add_user('user', '12345', os.getcwd(), perm='elradfmwM')
    handler = FTPHandler
    handler.authorizer = authorizer
    handler.banner = "ftp works."
    address = ('0.0.0.0', 2121)
    server = FTPServer(address, handler)
    server.max_cons = 256
    server.max_cons_per_ip = 5
    server.serve_forever()

if __name__ == '__main__':
    main()
Alan Kavanagh
  • 9,425
  • 7
  • 41
  • 65
alex stq
  • 39
  • 1
  • 10
  • Have you tried the [*virtual* option of a FileSystem](http://pyftpdlib.readthedocs.io/en/latest/api.html#filesystem) presented by pyftpdlib? – Serge Ballesta Nov 01 '17 at 18:06
  • would you try to put it in a code for me. my python file is in h:\\ftp.py – alex stq Nov 03 '17 at 09:06
  • You're giving the user all available permissions (`perm='elradfmwM'`) and setting their home directory to the current working directory (`os.getcwd()`). This is a bad idea for a few reasons; mostly because they will have access to any file on the server. If you're going to make real use of pyftpdlib you'll probably want to write your own authorizer, not use the provided `DummyAuthorizer` – DaveMongoose Jan 03 '18 at 17:15

0 Answers0