首页主机资讯Ubuntu FTP Server文件共享

Ubuntu FTP Server文件共享

时间2025-10-24 02:26:03发布访客分类主机资讯浏览1367
导读:Ubuntu FTP Server File Sharing Setup Guide (Using vsftpd vsftpd (Very Secure FTP Daemon is the most widely used FTP se...

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):

  • Disable Anonymous Access: Prevent unauthorized users from logging in.
    anonymous_enable=NO
    
  • Allow Local Users: Enable login for system users (e.g., the user you’ll create).
    local_enable=YES
    
  • Enable Write Permissions: Allow users to upload/download files.
    write_enable=YES
    
  • Restrict Users to Home Directories: Improve security by confining users to their home folders.
    chroot_local_user=YES
    allow_writeable_chroot=YES  # Required if chroot is enabled (lets users write to their home directory).
    
  • Configure Passive Mode: Essential for firewall/NAT environments (specify port range for data connections).
    pasv_enable=YES
    pasv_min_port=50000
    pasv_max_port=50100
    

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:

  • Command Line:
    ftp localhost
    
    Enter the FTP user’s credentials. If successful, you’ll see the server’s welcome message and can use commands like ls (list files) or put (upload).
  • FileZilla:
    • Open FileZilla and enter your server’s IP address, username, and password in the “Quick Connect” bar.
    • Click “Connect” to access the server’s files.

Key Troubleshooting Tips

  • Login Failed (530 Error): Verify the username/password and ensure local_enable=YES is set in /etc/vsftpd.conf. Check the PAM service name in the config file matches vsftpd.
  • Passive Mode Issues: Ensure the passive port range (e.g., 50000-50100) is open in your firewall and correctly configured in vsftpd.conf.
  • Permission Denied: Confirm the user’s home directory has 755 permissions and is owned by the user (e.g., chown ftpuser:ftpuser /home/ftpuser).

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.

声明:本文内容由网友自发贡献,本站不承担相应法律责任。对本内容有异议或投诉,请联系2913721942#qq.com核实处理,我们将尽快回复您,谢谢合作!


若转载请注明出处: Ubuntu FTP Server文件共享
本文地址: https://pptw.com/jishu/734147.html
Ubuntu FTP Server更新维护 Ubuntu FTP Server备份策略

游客 回复需填写必要信息