ubuntu

Ubuntu FTP Server文件共享

小樊
47
2025-10-23 16:56:42
栏目: 智能运维

Ubuntu FTP Server File Sharing Setup Guide (Using vsftpd)

vsftpd (Very Secure FTP Daemon) is the most widely used FTP server software on Ubuntu due to its security and stability. Below is a step-by-step guide to setting up an FTP server for file sharing, including key configurations and troubleshooting tips.

1. Install vsftpd

Update your system’s package list and install vsftpd using the following commands:

sudo apt update
sudo apt install vsftpd

2. Configure vsftpd

Edit the vsftpd configuration file to enable essential features and enhance security:

sudo nano /etc/vsftpd.conf

Modify or add the following key parameters (uncomment lines by removing the # if necessary):

Save changes (Ctrl+O, Enter) and exit (Ctrl+X).

3. Restart vsftpd

Apply configuration changes by restarting the service:

sudo systemctl restart vsftpd

Enable automatic startup on boot:

sudo systemctl enable vsftpd

4. Create an FTP User

Create a dedicated FTP user (replace ftpuser with your preferred username):

sudo adduser ftpuser

Set a strong password and complete the prompts.
Set the user’s home directory permissions to ensure proper access:

sudo chown ftpuser:ftpuser /home/ftpuser
sudo chmod 755 /home/ftpuser

5. Configure the Firewall

If you’re using UFW (Uncomplicated Firewall), allow FTP ports to permit incoming connections:

sudo ufw allow 21/tcp       # Standard FTP control port
sudo ufw allow 50000:50100/tcp  # Passive mode data ports (adjust to your config)
sudo ufw reload

For iptables, use these commands (replace with your passive port range):

sudo iptables -A INPUT -p tcp --dport 21 -j ACCEPT
sudo iptables -A INPUT -p tcp --dport 50000:50100 -j ACCEPT
sudo service iptables save

6. Test the FTP Connection

Use an FTP client (e.g., FileZilla) or command line to verify connectivity:

Key Troubleshooting Tips

This setup provides a secure and functional FTP server for file sharing on Ubuntu. For enhanced security, consider using SFTP (SSH File Transfer Protocol) instead, which encrypts all traffic by default.

0
看了该问题的人还看了