Created
October 1, 2015 12:19
-
-
Save ekinertac/499af851c8d0cd89c702 to your computer and use it in GitHub Desktop.
Temporary FTP Server
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# ftpserver-cli.py | |
import sys | |
sys.path.append("/home/ekinertac") # enter your proper path here | |
import argparse | |
from pyftpdlib.authorizers import DummyAuthorizer | |
from pyftpdlib.handlers import FTPHandler | |
from pyftpdlib.servers import FTPServer | |
def processCmdLineOptions(): | |
global optparser | |
optparser = argparse.ArgumentParser(description="ftpserver-cli", formatter_class=argparse.RawDescriptionHelpFormatter) | |
optparser.add_argument('-u', '--username', action='store', type=str, default="user", help="username") | |
optparser.add_argument('-p', '--password', action='store', type=str, default="12345", help="password") | |
optparser.add_argument('-t', '--port', action='store', type=int, default="21", help="port") | |
optparser.add_argument('-d', '--directory', action='store', type=str, default="/home", help="port") | |
optargs = optparser.parse_args(sys.argv[1:]) #(sys.argv) | |
return optargs | |
optargs = processCmdLineOptions() | |
print("Using: user: %s pass: %s port: %d dir: %s" % (optargs.username, optargs.password, optargs.port, optargs.directory)) | |
authorizer = DummyAuthorizer() | |
authorizer.add_user(optargs.username, optargs.password, optargs.directory, perm="elradfmw") | |
#authorizer.add_anonymous("/home/nobody") | |
handler = FTPHandler | |
handler.authorizer = authorizer | |
server = FTPServer(("0.0.0.0", optargs.port), handler) | |
server.serve_forever() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment