A practical walkthrough of installing and configuring a vsftpd FTP server on a Raspberry Pi, including package installation, configuration file editing, directory setup, and service management.
Setting Up FTP Server
We're going to set up an FTP server on our demo Pi, so that way we can connect to it and see what traffic looks like.
The first thing that I'm going to need to do is install the FTP services. So what I'm going to do is pull up a terminal window on the demo Pi machine. I'm on the demo Pi. I'll make it a little bit larger so we can see this.
And then within here, I'm going to type in sudo, because I need elevated permissions for this, and apt-get, and we are just going to update all of the packages on this machine to make sure that everything is up to date. Once everything's up to date, I'm going to elevate the permissions once again and use our apt-get, and this time I want to install, and I'm going to install vsftpd. So I'll install this. It takes about a minute for it to install.
Once it's installed, we can jump into our configuration file and edit some of the configurations. So I'm going to use my elevated permissions once again, and I'm going to use nano to edit the /etc/vsftpd.conf file. There's a few items that we'll uncomment and a couple of changes that we're going to make in this.
The first one is this anonymous_enable, no, which is already uncommented, so I don't need to worry about that. local_enable, yes — that's uncommented, I don't need to worry about that. write_enable, yes: I want them to be able to write, so we're going to uncomment that. And then scroll down to the local_umask. This is setting up some permissions, and I'm going to uncomment that. And then scroll down to find chroot_local_user, yes. So I'm going to scroll down till I find that and delete the comment off of this one.
And the last thing that I'm going to do is scroll to the end of the document and add this user_sub_token=$USER and local_root=/home/$USER/ftp. I'm going to exit out of this document now and save it.
So the next thing that I'm going to do is create a directory that we're going to actually be accessing using these FTP services. So I'm going to list out to see what's inside the home directory, and it is demo pi. What that is, demo pi is the user that I'm creating, and that's the home directory for it. So that's what we're going to actually use to access the server.
So I'm actually going to look into that directory now. And we can see that there's a few things in here; ftp is not one of them. So I'm going to make a directory inside of there. So mkdir, make a directory inside home/demo. And then I'm going to create a directory within there that we're actually going to access; we'll call this files.
So now, if I list out what's inside of my demo pi directory, I can see that ftp is inside of that.
So the next thing that I want to do is change or modify the permissions that are on that directory. So I'm going to use the chmod command and a-w — that changes the permissions of, we want to change, home/demo pi/ftp — and we are going to hit enter for that to change the permissions on that particular file.
So the next thing that I'm going to do is just create a test file, so that way we can practice downloading something. So I'm going to type in my nano program here, and I am going to create it in the home directory, in the demo pi home directory. It'll be the FTP folder, and we have that files folder, so I'll create it there. And I'm going to call it — we'll just call it maybe test.txt, how about that. And then in here, this is a test. I'm going to hit Ctrl X and save this, and save it to that location.
And then let's see if we can download this. So we've made changes to our configuration file, and we also made changes to the files. Now, since we made changes to the permissions of the files and created this test file, we wouldn't need to restart after those operations. But after reconfiguring the configuration file, we do need to restart this.
So we can either restart by the reboot command and then rebooting the server, or I can restart this specific service. So I can type in sudo service vsftpd restart to restart the service. So that's what I'm going to do, and we'll get that restarted. Now all there is to do is test this out.
TechKnowSurge builds IT and cybersecurity professionals through hands-on, concept-first training built around real understanding — not memorization. Free interactive tools, structured programs, and 25+ years of real-world experience, all in one place.
Explore free tools and programs →