I generally prefer Samba over FTP as it gives a better experience by allowing user to access the files as if they're still on local disk. And, unlike FTP, media files can be played directly from Samba share. But one might still need FTP server as it offers better performance over Samba.
If the router has at least 8MB flash ROM and happens to run DD-WRT MEGA build, very likely there is a proftpd FTP server built in. But here I'll take some extra trouble to use lightweight vsftpd instead.
So why vsftpd? The main reason is its size. The proftpd is 500KB while vsftpd is only 100KB! This makes it perfect for embedded systems. Also, vsftpd is easy to use and setup.
- Disable stock ProFTPD server
For DD-WRT, it's in Services->NAS. Set it to Disable then click "Apply Settings".
- Install vsftpd
Assume you have followed previous tutorials and has a working opkg system, now use PuTTY to log in the router and run
opkg install vsftpd
- (optional)Add a user for anonymous FTP access
*ignore this part if you've follow the Samba guide, then this user is already in the system.
Create or add to /opt/etc/init.d/adduser with following line:
grep -q nobody /etc/passwd || echo 'nobody:x:65534:65534:nobody:/mnt:/bin/false' >> /etc/passwd
Above is one single line and will create a new user "nobody" with no valid password and login shell(thus can't be used for login). Then set it to run during boot up:
chmod a+x /opt/etc/init.d/adduser
ln -s /opt/etc/init.d/adduser /opt/etc/init.d/S05adduser
- vsftpd.conf, the configuration file for vsftpd
Edit file /opt/etc/vsftpd.conf with below(delete all previous contents if the file is not empty)
#Change it if you want to use other port
#Set it to NO if you don't want anonymous FTP access
#local user used for anonymous FTP access, here is "nobody"
For a full list of options, please refer to vsftpd website. These basic options here should be enough for home use. With the settings above, the anonymous user will be locked to "/mnt" folder(if you enable the anonymous option). Can also login with other valid user accounts like "root" or "share" with no restriction.
- Set vsftpd to run as a service
Create file /opt/etc/init.d/vsftpd(delete all previous contents if the file is not empty)
[ -d /var/run/vsftpd ] || mkdir /var/run/vsftpd
kill -9 $(pidof vsftpd)
Then set it to run as a service
chmod a+x /opt/etc/init.d/vsftpd
ln -s /opt/etc/init.d/vsftpd /opt/etc/init.d/S60vsftpd