DEV Community

Ishan Jarwal
Ishan Jarwal

Posted on

Stream your movies to VLC across devices with this simple FTP Server with python.

Sometimes you just need to move a few files between machines on your local network.

You don't want to configure a full FTP daemon, create system users, edit configuration files, and set up a permanent service. You just want to share a directory, grab the files from another machine, and shut the server down when you're finished.

Python makes this surprisingly easy with pyftpdlib.

Unlike HTTP, Python doesn't ship with a built-in FTP server. If you've used:

python -m http.server
Enter fullscreen mode Exit fullscreen mode

you might expect something similar for FTP. There isn't an FTP equivalent in Python's standard library, but pyftpdlib fills that gap nicely.

For temporary development environments, home networks, VMs, and quick file transfers, it's often all you need.

Installing pyftpdlib on Arch Linux

On Arch Linux, installing packages globally with pip isn't generally the best idea because the system Python environment is managed by pacman.

There are two sensible ways to install pyftpdlib.

Option 1: Install with Pacman

If the package is available in your configured repositories, this is the simplest approach:

sudo pacman -S python-pyftpdlib
Enter fullscreen mode Exit fullscreen mode

Once installed, you can invoke it directly through Python:

python -m pyftpdlib
Enter fullscreen mode Exit fullscreen mode

Option 2: Use a Virtual Environment

For something temporary—or if you prefer keeping Python packages isolated—a virtual environment works well:

python -m venv .venv
source .venv/bin/activate
pip install pyftpdlib
Enter fullscreen mode Exit fullscreen mode

Then start the server with:

python -m pyftpdlib
Enter fullscreen mode Exit fullscreen mode

When you're finished, leave the environment with:

deactivate
Enter fullscreen mode Exit fullscreen mode

The Simplest FTP Server

Suppose you're inside a directory containing files you want to share:

cd ~/Downloads
Enter fullscreen mode Exit fullscreen mode

Start the server:

python -m pyftpdlib
Enter fullscreen mode Exit fullscreen mode

That's it.

pyftpdlib starts an FTP server and exposes the current working directory.

You'll see output indicating the address and port the server is listening on.

By default, this is useful primarily as a quick anonymous FTP server. Anonymous users are restricted to downloading files rather than modifying the directory.

Sharing a Specific Directory

You don't actually have to cd into the directory first.

You can tell pyftpdlib exactly which directory should become the FTP root:

python -m pyftpdlib -d ~/Downloads
Enter fullscreen mode Exit fullscreen mode

This is particularly useful when you're running the command from scripts or another working directory.

For example:

python -m pyftpdlib -d ~/Videos
Enter fullscreen mode Exit fullscreen mode

Now clients connecting to the FTP server will see the contents of ~/Videos.

Choosing the Port

FTP traditionally uses port 21.

On Linux, however, ports below 1024 normally require elevated privileges. Running an entire temporary Python FTP server as root just to get port 21 isn't a great trade-off.

Instead, use a higher port such as 2121:

python -m pyftpdlib -p 2121
Enter fullscreen mode Exit fullscreen mode

Or combine it with a directory:

python -m pyftpdlib -p 2121 -d ~/Downloads
Enter fullscreen mode Exit fullscreen mode

I generally prefer 2121 for temporary FTP servers because it makes the purpose obvious while avoiding root privileges.

Setting a Username and Password

Anonymous access is convenient, but you probably don't want everyone on your network accessing the directory.

pyftpdlib lets you specify credentials directly from the command line.

For example:

python -m pyftpdlib \
    -u ishu \
    -P 'my-password' \
    -p 2121 \
    -d ~/Downloads
Enter fullscreen mode Exit fullscreen mode

Here:

  • -u ishu sets the FTP username.
  • -P 'my-password' sets the password.
  • -p 2121 runs the server on port 2121.
  • -d ~/Downloads makes ~/Downloads the FTP root.

A client would then connect using:

Username: ishu
Password: my-password
Enter fullscreen mode Exit fullscreen mode

One thing worth remembering: putting passwords directly into commands can leave them in your shell history. That's fine for disposable local credentials, but don't reuse an important password here.

Allowing File Uploads

So far, we're mainly using FTP to download files.

Sometimes the opposite is more useful. Maybe you want to quickly send files from your phone or another computer back to your Arch machine.

Enable write access with:

python -m pyftpdlib -w
Enter fullscreen mode Exit fullscreen mode

Combined with authentication and a specific directory:

python -m pyftpdlib \
    -u ishu \
    -P 'temporary-password' \
    -w \
    -p 2121 \
    -d ~/Downloads
Enter fullscreen mode Exit fullscreen mode

The -w flag enables write operations, allowing clients to upload and modify files.

Be more careful with this option. Anyone who obtains the credentials may be able to modify files inside the shared directory.

For temporary transfers, I like creating a dedicated directory:

mkdir -p ~/ftp-share
Enter fullscreen mode Exit fullscreen mode

Then expose only that directory:

python -m pyftpdlib \
    -u ishu \
    -P 'temporary-password' \
    -w \
    -p 2121 \
    -d ~/ftp-share
Enter fullscreen mode Exit fullscreen mode

That way you're not accidentally exposing your home directory or something more important.

Making the Server Reachable from Other Devices

If you're connecting from another computer, binding only to localhost won't help. The server needs to listen on an interface reachable from your network.

You can explicitly bind it to all interfaces:

python -m pyftpdlib \
    -i 0.0.0.0 \
    -p 2121 \
    -d ~/ftp-share
Enter fullscreen mode Exit fullscreen mode

With authentication and uploads enabled, a more complete command becomes:

python -m pyftpdlib \
    -i 0.0.0.0 \
    -p 2121 \
    -u ishu \
    -P 'temporary-password' \
    -w \
    -d ~/ftp-share
Enter fullscreen mode Exit fullscreen mode

Now you need the local IP address of your Arch machine.

One quick way to find it is:

ip addr
Enter fullscreen mode Exit fullscreen mode

Or:

hostname -I
Enter fullscreen mode Exit fullscreen mode

Suppose your machine is:

192.168.1.42
Enter fullscreen mode Exit fullscreen mode

Your FTP server would then be reachable at:

ftp://192.168.1.42:2121
Enter fullscreen mode Exit fullscreen mode

from other devices on the same network, assuming your firewall and network configuration allow the connection.

Connecting with curl

You don't necessarily need a graphical FTP client.

curl works perfectly well for quick transfers.

List the files available on the server:

curl ftp://192.168.1.42:2121/
Enter fullscreen mode Exit fullscreen mode

With authentication:

curl -u ishu ftp://192.168.1.42:2121/
Enter fullscreen mode Exit fullscreen mode

curl will prompt for the password instead of forcing you to put it directly in the command.

Download a file:

curl -u ishu \
    ftp://192.168.1.42:2121/example.zip \
    -o example.zip
Enter fullscreen mode Exit fullscreen mode

If write access is enabled, upload a file:

curl -u ishu \
    -T photo.jpg \
    ftp://192.168.1.42:2121/
Enter fullscreen mode Exit fullscreen mode

Connecting with an FTP Client

You can also use a traditional command-line FTP client:

ftp 192.168.1.42 2121
Enter fullscreen mode Exit fullscreen mode

Enter the username and password when prompted.

Graphical clients such as FileZilla work as well. You'd configure roughly:

Host: 192.168.1.42
Port: 2121
Protocol: FTP
Username: ishu
Password: your temporary password
Enter fullscreen mode Exit fullscreen mode

A Command Worth Remembering

For a temporary authenticated FTP drop folder, the command I find most useful is:

python -m pyftpdlib \
    -i 0.0.0.0 \
    -p 2121 \
    -u ishu \
    -P 'temporary-password' \
    -w \
    -d ~/ftp-share
Enter fullscreen mode Exit fullscreen mode

It gives you a specific shared directory, a non-privileged port, authentication, upload support, and access from other devices on your network.

Once the transfer is finished, press:

Ctrl+C
Enter fullscreen mode Exit fullscreen mode

and the server disappears.

No daemon to disable. No service left running in the background. No permanent FTP configuration to maintain.

A Few Security Notes

This setup is best thought of as a temporary file-transfer tool, particularly on a trusted local network.

Traditional FTP does not encrypt credentials or file transfers. Don't expose this server directly to the public internet, and don't use a password that you use elsewhere.

For transfers across untrusted networks, SSH/SFTP is usually the better choice:

sftp username@server
Enter fullscreen mode Exit fullscreen mode

If all you need is downloading files without authentication or uploads, Python's built-in HTTP server may be even simpler:

python -m http.server 8000 --directory ~/ftp-share
Enter fullscreen mode Exit fullscreen mode

The interesting thing about pyftpdlib isn't that it replaces a proper FTP server. It doesn't need to.

Its value is that when you need an FTP server right now, for one directory and perhaps only ten minutes, you can have one running before you'd normally finish editing the configuration file for a traditional FTP daemon.

Top comments (0)