FTP server | Generated by AI

Home PDF

To set up an FTP server on Ubuntu so you can access your files (like those .mkv files in /var/www/movies/) from your iPad or other devices, you can use vsftpd (Very Secure FTP Daemon), a lightweight and secure option. Here’s a step-by-step guide tailored to your setup:

Prerequisites

Step 1: Install vsftpd

  1. Update Package List:
    sudo apt update
    
  2. Install vsftpd:
    sudo apt install vsftpd -y
    
  3. Verify Installation:
    sudo systemctl status vsftpd
    
    • It should say active (running). If not, start it:
      sudo systemctl start vsftpd
      sudo systemctl enable vsftpd  # Start on boot
      

Step 2: Configure vsftpd

The default config file is /etc/vsftpd.conf. We’ll tweak it for basic access.

  1. Backup the Original Config:
    sudo cp /etc/vsftpd.conf /etc/vsftpd.conf.bak
    
  2. Edit the Config:
    sudo nano /etc/vsftpd.conf
    

    Make these changes:

    • Enable local users:
      local_enable=YES
      
    • Allow file uploads (optional, if you want to upload files):
      write_enable=YES
      
    • Restrict users to their home directories (optional, for security):
      chroot_local_user=YES
      
    • Point to your movies directory (optional, see Step 3 for user setup):
      • By default, users access their home directories. We’ll adjust this later.

    Save (Ctrl + O, Enter, Ctrl + X).

  3. Restart vsftpd:
    sudo systemctl restart vsftpd
    

Step 3: Set Up an FTP User

You can use an existing user or create a new one to access /var/www/movies/.

Option 1: Use an Existing User

If you want to use your current Ubuntu user (e.g., user):

  1. Check Your Username:
    whoami
    
  2. Set Password (if needed):
    sudo passwd user  # Replace "user" with your username
    
  3. Link to Movies Directory:
    • By default, this user’s home directory (e.g., /home/user/) is the FTP root. To access /var/www/movies/, create a symlink:
      ln -s /var/www/movies/ /home/user/movies
      
    • Or, adjust permissions (less secure):
      sudo chown -R user:user /var/www/movies
      

Option 2: Create a Dedicated FTP User

For better security:

  1. Add User:
    sudo adduser ftpuser
    
    • Follow prompts to set a password and details.
  2. Set Home Directory to Movies:
    sudo usermod -d /var/www/movies ftpuser
    sudo chown -R ftpuser:ftpuser /var/www/movies
    
  3. Restrict Access (if chroot_local_user=YES):
    • Ensure /var/www/movies is writable by ftpuser:
      sudo chmod -R 755 /var/www/movies
      

Step 4: Open Firewall Ports

FTP uses ports 20 and 21 by default.

  1. Allow FTP in UFW:
    sudo ufw allow 21/tcp
    sudo ufw allow 20/tcp
    sudo ufw status
    
    • Should show 20/tcp ALLOW and 21/tcp ALLOW.
  2. Restart vsftpd:
    sudo systemctl restart vsftpd
    

Step 5: Test FTP from iPad

You’ll need an FTP client app on your iPad.

Streaming from FTP

Step 6: Verify Access

Troubleshooting

Final Notes

Your iPad now has FTP “magic” to access your Ubuntu server’s files! Let me know if you hit any issues.


Back 2025.03.16 Donate