Skip to content

Instantly share code, notes, and snippets.

@gitllermopalafox
Created May 31, 2014 09:10
Show Gist options
  • Save gitllermopalafox/89abeeb5720f64564fc7 to your computer and use it in GitHub Desktop.
Save gitllermopalafox/89abeeb5720f64564fc7 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# install pyftpdlib
# (shell) > easy_install https://pyftpdlib.googlecode.com/files/pyftpdlib-1.0.1.tar.gz
# tutorial
# https://code.google.com/p/pyftpdlib/wiki/Tutorial
from pyftpdlib.authorizers import DummyAuthorizer
from pyftpdlib.handlers import FTPHandler
from pyftpdlib.servers import FTPServer
authorizer = DummyAuthorizer()
# - Read permissions:
# "e" = change directory (CWD, CDUP commands)
# "l" = list files (LIST, NLST, STAT, MLSD, MLST, SIZE commands)
# "r" = retrieve file from the server (RETR command)
# - Write permissions
# "a" = append data to an existing file (APPE command)
# "d" = delete file or directory (DELE, RMD commands)
# "f" = rename file or directory (RNFR, RNTO commands)
# "m" = create directory (MKD command)
# "w" = store a file to the server (STOR, STOU commands)
# "M" = change mode/permission (SITE CHMOD command) New in 0.7.0
authorizer.add_user('username', 'password', '/tmp', perm='elradfmw')
handler = FTPHandler
handler.authorizer = authorizer
server = FTPServer(('127.0.0.1', 2121), handler)
server.serve_forever()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment