FTP server | Generated by AI
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
- You’re on Ubuntu (e.g., 22.04 or 24.04 as of March 15, 2025).
- You have sudo privileges.
- Your Nginx server is at
192.168.1.27
, and files are in/var/www/movies/
.
Step 1: Install vsftpd
- Update Package List:
sudo apt update
- Install vsftpd:
sudo apt install vsftpd -y
- 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
- It should say
Step 2: Configure vsftpd
The default config file is /etc/vsftpd.conf
. We’ll tweak it for basic access.
- Backup the Original Config:
sudo cp /etc/vsftpd.conf /etc/vsftpd.conf.bak
- 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
). - Enable local users:
- 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
):
- Check Your Username:
whoami
- Set Password (if needed):
sudo passwd user # Replace "user" with your username
- 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
- By default, this user’s home directory (e.g.,
Option 2: Create a Dedicated FTP User
For better security:
- Add User:
sudo adduser ftpuser
- Follow prompts to set a password and details.
- Set Home Directory to Movies:
sudo usermod -d /var/www/movies ftpuser sudo chown -R ftpuser:ftpuser /var/www/movies
- Restrict Access (if
chroot_local_user=YES
):- Ensure
/var/www/movies
is writable byftpuser
:sudo chmod -R 755 /var/www/movies
- Ensure
Step 4: Open Firewall Ports
FTP uses ports 20 and 21 by default.
- Allow FTP in UFW:
sudo ufw allow 21/tcp sudo ufw allow 20/tcp sudo ufw status
- Should show
20/tcp ALLOW
and21/tcp ALLOW
.
- Should show
- Restart vsftpd:
sudo systemctl restart vsftpd
Step 5: Test FTP from iPad
You’ll need an FTP client app on your iPad.
Recommended iPad App: FileZilla or FE File Explorer
- FileZilla (Free):
- Install from the App Store (search “FileZilla”).
- Open FileZilla.
- Tap New Site or Connect.
- Enter:
- Host:
192.168.1.27
- Username:
ftpuser
(or your username) - Password: [your password]
- Port: 21 (default)
- Host:
- Tap Connect.
- FE File Explorer (Free with in-app purchases):
- Install from the App Store.
- Tap + > FTP.
- Enter the same details as above.
- Connect.
Streaming from FTP
- Most FTP apps let you browse files. To stream
.mkv
files:- Tap the
.mkv
file in the app. - If it doesn’t play directly, download a streaming app like VLC for Mobile (see previous response), then use its Network Stream option with an FTP URL:
ftp://ftpuser:password@192.168.1.27/yourfile.mkv
- Tap the
Step 6: Verify Access
- From your iPad, connect to
192.168.1.27
via the FTP app. - You should see
/var/www/movies/
contents (e.g.,yourfile.mkv
). - Tap to preview or stream (depending on the app).
Troubleshooting
- Connection Refused: Check
sudo ufw status
and ensure ports 20/21 are open. Verify vsftpd is running (sudo systemctl status vsftpd
). - Permission Denied: Confirm the user owns or can read
/var/www/movies/
(ls -l /var/www/movies/
). - 404 or No Files: Ensure the directory path matches the user’s home or symlink setup.
Final Notes
- Security: For a local network, this setup is fine. For external access, consider FTPS (encrypted FTP) by enabling SSL in
vsftpd.conf
. - Nginx vs. FTP: You’re already streaming via HTTP with Nginx—FTP adds file management. Use VLC on your iPad for HTTP streaming if FTP setup feels redundant.
Your iPad now has FTP “magic” to access your Ubuntu server’s files! Let me know if you hit any issues.