Step 1: Install vsftpd
To set up an FTP server in Linux, first, you have to ensure vsftpd is installed:
For Ubuntu/Debian:
sudo apt update
sudo apt install vsftpd -y
For CentOS/RHEL:
sudo yum install vsftpd -y
Step 2: Basic Configuration of vsftpd
Configure vsftpd to allow basic FTP connections and set user restrictions.
- Open the vsftpd configuration file:
sudo nano /etc/vsftpd.conf
- Edit/add the following settings for a secure FTP setup, the FTP folder in this case will be /home/$USER/FTP:
anonymous_enable=NO local_enable=YES write_enable=YES chroot_local_user=YES allow_writeable_chroot=YES chroot_local_user=YES user_sub_token=$USER local_root=/home/$USER/ftp
- Save and close the file.
- Restart vsftpd to apply changes:
sudo systemctl restart vsftpd
Step 3: Create FTP Users
To allow specific users to access the FTP server:
- Create a new user (replace <username> with the desired username):
sudo adduser <username>
- Create an FTP upload directory for the user:
sudo mkdir /home/<username>/ftp sudo chown <username> /home/<username>/ftp
Step 4: Test the FTP Server Configuration
To connect to the FTP server, use an FTP client like FileZilla:
- Open FileZilla
- Enter your server IP, username, and password, then click Connect.
Troubleshooting Tips
Check logs for errors:
sudo tail /var/log/vsftpd.log
Ctrl+C Sanctuary
The entire guide is distilled into copy-paste perfection—tested, hassle-free, and ready to go.
Ubuntu/ Debian Based :
sudo apt update
sudo apt install vsftpd -y
sudo echo -e "write_enable=YES\nchroot_local_user=YES\nallow_writeable_chroot=YES\nchroot_local_user=YES\nuser_sub_token=$USER\nlocal_root=/home/$USER/ftp" >> /etc/vsftpd.conf
sudo systemctl restart vsftpd
useradd -m ftpuser;echo "ftpuser:ftpuser" | chpasswd
sudo mkdir /home/ftpuser/ftp
sudo chown ftpuser /home/ftpuser/ftp
Fedora/ RHEL Based :
sudo dnf update -y
dnf install vsftpd -y
sudo echo -e "write_enable=YES\nchroot_local_user=YES\nallow_writeable_chroot=YES\nchroot_local_user=YES\nuser_sub_token=$USER\nlocal_root=/home/$USER/ftp" >> /etc/vsftpd.conf
sudo systemctl restart vsftpd
useradd -m ftpuser;echo "ftpuser:ftpuser" | chpasswd
sudo mkdir /home/ftpuser/ftp
sudo chown ftpuser /home/ftpuser/ftp
标签:FTP,set,Protocol,sudo,vsftpd,home,ftpuser,YES
From: https://blog.csdn.net/Evoxt/article/details/145302765