You can get an FTP server going as easy as one two three using pyftpdlib:
- Install with pip
pip install --user pyftpdlib
- Run with
python -m pyftpdlib
, add -w
if you want write access too.
- there is no step three :)
You now have an ftp server which you can log in to anonymously sharing your home directory. This is meant more as a test of the module, but it does what it says on the tin.
This command:
python -m pyftpdlib --directory=FTP --port=2121 --write
will serve, without root privileges, on port 2121 and grant write access to anonymous users. It will also use the directory FTP
in the current working directory instead of your home. Type python ftpserver.py --help
to get information about all the options.
- log into it at
anonymous@localhost:2121/
Please note that this software is released under the terms of the MIT License, which means you can do basically what ever you please with it. Read the license text, it's only a few lines, and know your rights.
Now, this script doesn't support username and password as part of it's stand-alone functionality (for security reasons I imagine).
So I've added that feature:
You now have, in addition to all options I mentioned, the command line parameters
--username=USERNAME
and --password=PASSWORD
:
python ftpserver.py --port=2121 --username=ftpuser --password=3r2u389r2u333j
Again, use --help
to see them all.
This should be as easy as it gets.
I've also written a little gui for it:
Download it here (updated at rev. 6)
I'm sorry it's 3999 lines long, but it will do everything the original does. And i wanted to keep it all in one file.
When it's started without any parameters (i.e. make it executable and double click it, or create a launcher for it), it starts a little gui for you to configure your server. You can still import it as a python module or use the above command line fu.
Known issues:
I've not bothered with anything other than port 2121. This should be simple, making the port configurable requires complex error handling which I don't want the user to bother with. 2121 should always work fine.
It won't warn you, like the command line does, about using an insecure configuration. I.e. not setting a password or something like that.
EDIT: since the API of pyftpdlib
and ftpserver.py
changed (and the ubuntu pastebin links are gone); most of the above post doesn't work anymore. For the (2014) version of pyftpdlib
, use this script (ftpserver-cli.py
) to achieve the same as above:
#!/usr/bin/env python
# ftpserver-cli.py
import sys
sys.path.append("/path/to/pyftpdlib-svn") # 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/stefano/Projekte/", 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(("127.0.0.1", optargs.port), handler)
server.serve_forever()
call with:
$ sudo python ftpserver-cli.py --directory=/tmp/srvtest
Using: user: user pass: 12345 port: 21 dir: /tmp/srvtest
[I 14-03-02 21:40:57] >>> starting FTP server on 127.0.0.1:21, pid=19286 <<<
...
You can resume any download using the wget command provided:
- You know the url of the file
- You have the partially downloaded file and know its location
- The server the file is on supports resuming downloads
Getting the required information
In Chromium, go the the chrome://downloads/ page. Find the failed download that you want to resume. To get the url, right click on the "Retry download" link and click "Copy Link Address". The location to the file will be ~/Downloads/NAME.crdownload
- NAME is the file name that is displayed above the url in the entry on the chrome://downloads/ page.
Downloading the file
The command to resume the download is:
wget -c URL -O FILE
where URL is the url of the partially downloaded file and FILE is the location of the partially downloaded file. Make sure you escape any spaces in the file path.
If the server supports resuming downloads you will see a progress bar like this:
100%[++++++++++++++++++++++++========================>]
where the '+'s indicate what was previously downloaded and the '='s indicate what is currently being downloaded.
If the server doesn't support resuming downloads, you will get an error message and it will fail to download. In this case you have no choice but to restart the download.
Best Answer
wget
should work:wget
is tool for downloading files.-r
means recursive.-l 0
for infinite recursion, because-r
by default have recursion depth of 5.some_dir/
is relative to user home dir. If you want absolute path add one more/
after host name.Maybe you have to use
--user
and--password
arguments to get it to work on Ubuntu.(according to https://stackoverflow.com/questions/113886/how-do-you-recursively-ftp-a-folder-in-linux)