FTP -SENDING FILE BETWEEN WINDOWS AND RASPBERRY PI

Photo of author

By Jackson Taylor

Home » Electronics Topics » Raspberry Pi » FTP -SENDING FILE BETWEEN WINDOWS AND RASPBERRY PI

As an Amazon Associate we earn from qualifying purchases.

Sooner or later you need to move a script, a log file or a photo between your Windows PC and a Raspberry Pi. Doing it with a USB stick works, but it gets tedious. A better option is to set up an FTP server on the Pi and drag and drop files from Windows using a free client such as FileZilla.

This guide shows how to install the vsftpd FTP server on the Pi, configure it, and connect from Windows. It also explains the difference between FTP and SFTP, since the two are easy to mix up.

FTP or SFTP: which one should you use?

FTP (File Transfer Protocol) uses port 21 by default. It is simple, but it sends your username and password as plain text. That is acceptable on a trusted home network, but not over the internet.

Hardware Hack

Stop Buying New Batteries for Your Tech

Electronics are expensive, but their power sources don't have to be. Discover the simple engineering trick to recondition dead batteries and bring your gadgets back to 100% capacity.

Watch the Free Video

SFTP (SSH File Transfer Protocol) uses port 22 and is encrypted. It runs through the SSH service, so you do not need vsftpd at all. If SSH is enabled on your Pi, SFTP already works.

  • FTP with vsftpd: needs the setup below, connects on port 21.
  • SFTP: needs only SSH enabled, connects on port 22.

The two are not interchangeable. If you install vsftpd but then enter port 22 in your client, the connection will fail or use the wrong protocol. Match the port to the method you chose.

What you need

  • A Raspberry Pi with Raspberry Pi OS and a network connection (Wi-Fi or Ethernet).
  • A Windows PC on the same network.
  • The Pi’s username and password.
  • The Pi’s IP address. If you do not know it, you can find the Raspberry Pi’s IP address without a monitor. If you are on the Pi itself, run hostname -I in a terminal.

Step 1: Install vsftpd on the Raspberry Pi

Open a terminal on the Pi, or log in over SSH, and install the server:

sudo apt-get install vsftpd

Step 2: Create the folders for file transfer

The setup below locks each user into a single folder, so create it first. The examples use the default pi user. If your username is different, replace pi with it.

mkdir -p /home/pi/ftp/files
chmod a-w /home/pi/ftp

The ftp folder is the user’s FTP root, and the files folder inside it is where you will upload and download. The chmod a-w command removes write permission from the root folder. This is needed because vsftpd refuses to start a chroot session when the root folder is writable.

See also
RASPBERRY PI

Linux file names are case sensitive. Use the same lowercase ftp in every command and in the config file, otherwise vsftpd will not find the folder.

Step 3: Edit the vsftpd configuration

Open the configuration file in the nano editor:

sudo nano /etc/vsftpd.conf

Make sure the following lines are present and not commented out (no # at the start). Some already exist in the file, so change them instead of adding duplicates. Add any that are missing.

anonymous_enable=NO
local_enable=YES
write_enable=YES
local_umask=022
chroot_local_user=YES
user_sub_token=$USER
local_root=/home/$USER/ftp

Here is what each setting does:

  • anonymous_enable=NO blocks logins without a password.
  • local_enable=YES lets normal Pi users log in.
  • write_enable=YES allows uploads, deletes and renames.
  • local_umask=022 gives new files sensible default permissions.
  • chroot_local_user=YES keeps users inside their own folder.
  • user_sub_token=$USER and local_root=/home/$USER/ftp send each user to the ftp folder in their own home directory.

Press Ctrl+X, then Y, then Enter to save and exit.

Sustainable Tech

Keep Toxic E-Waste Out of Landfills

Don't throw away your failing laptop, phone, or car batteries. Learn how to recondition them at home in just a few hours. It's better for the planet—and your wallet.

Learn How It Works

Step 4: Restart the FTP service

Restart vsftpd so it reads the new settings:

sudo service vsftpd restart

To check that it is running, use sudo service vsftpd status. You should see it listed as active.

Step 5: Connect from Windows with FileZilla

Download and install FileZilla Client on your Windows PC. Then:

  1. Open FileZilla.
  2. Enter the Raspberry Pi’s IP address in the Host box.
  3. Enter your Pi username (the default on older installs is pi) and its password.
  4. Enter port 21 for FTP with vsftpd. Use port 22 only if you are connecting with SFTP.
  5. Click Quickconnect.

FileZilla may warn that the connection is not encrypted. On a home network that is expected for plain FTP. The remote folder window then opens on the right side, with your Windows files on the left.

Open the files folder on the Pi side, then drag and drop files in either direction. Uploads go into files, because the root folder is read-only by design.

See also
FINDING RASPBERRY IP ADDRESS WITHOUT DISPLAY USING NMAP AND LOGIN WITH PUTTY in windows

Using SFTP instead (no server setup)

If you prefer an encrypted connection, skip vsftpd and use SFTP. Enable SSH on the Pi through sudo raspi-config under the interface options. In FileZilla, enter sftp:// followed by the Pi’s IP address in the host box, use port 22, and connect with your Pi login. You will see the Pi’s normal home folder and can transfer files right away.

If you are not sure how to connect your Raspberry Pi to a laptop in the first place, set that up first. File transfer only works once the two devices can reach each other.

Troubleshooting common problems

Connection refused or timed out

Check that the Pi and the PC are on the same network and that the IP address is correct. Confirm that vsftpd is running, and that you used port 21 for FTP. Addresses can change after a reboot unless you reserve one in your router.

530 Login incorrect

The username or password is wrong, or local_enable=YES is missing from the config file. Passwords are case sensitive. If you still use a default password, change it with the passwd command, because default credentials are well known.

500 OOPS: refusing to run with writable root inside chroot

The ftp folder is writable. Run chmod a-w /home/pi/ftp again and upload into the files subfolder instead.

550 Permission denied when uploading

Check that write_enable=YES is set and that you are uploading to files, not the root folder. Also confirm that your user owns the files folder.

Other ways to reach your Pi

FTP is only for moving files. If you also want to see the Pi’s desktop from Windows, you can set up a VNC server or use Remote Desktop. To reach the Pi from outside your home, read how to access a Pi behind a router. Avoid exposing plain FTP to the internet.

See also
VIM editor -raspberry pi

FAQ

Is FTP safe to use on a Raspberry Pi?

On a trusted home network it is generally fine, but FTP does not encrypt passwords or data. For anything beyond that, use SFTP, which runs over SSH.

What port does FTP use on a Raspberry Pi?

vsftpd listens on port 21 by default. SFTP uses port 22, the same as SSH.

The Ultimate Money-Saving DIY Skill

From power tools and solar banks to your car, batteries are the most expensive part of your gear. Master the step-by-step DIY system to bring dead batteries back to life.

Get the Step-by-Step Guide

Do I need to install anything on Windows?

Only an FTP client such as FileZilla. Windows File Explorer can also open FTP addresses, but a dedicated client is easier for uploads and for SFTP.

Can I transfer files without installing an FTP server?

Yes. If SSH is enabled, SFTP works with no extra server software on the Pi, and tools like FileZilla or WinSCP can connect to it.

Revive Your Dead Electronics

Got a drawer full of dead gadgets or a failing car battery? Instead of paying a premium for replacements, use this simple trick to easily recondition them right from home.

See How It Works