Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Offer more directories via anonymous FTP UNIX
I think I finally figured out how to use something like links or aliases in an ftp server for anonymous logins.

First up there's a link on enabling anonymous ftp here on If you haven't set up an anonymous ftp server yet, I suggest you read and follow those instructions. Furthermore I suggest you set up a FireWall for security reasons.

The problem is that for security reasons, ftp servers do not allow anonymous users to access anything outside the dedicated ftp directory e.g. /Users/ftp. Therefore, neither soft links done by "ln -s file1" nor aliases to files and especially directories outside the ftp directory will work. Hard links done by "ln file1" will work, though, but they are hardly a replacement because you can't do hard links on directories therefore you'd have to link every single file and this may take a while if e.g. you want to serve up your collection of 23,156 MP3 songs in 2,167 directories :-)

The solution is to trick the ftp server into believing that linked files are real files within the /Users/ftp directory. And that can be done by NFS, Network File System, which is also built into Mac OS X.

Read the rest of this article if you'd like a detailed how-to on setting up NFS and sharing multiple directories via FTP.

[Editor's note: I have not done this on my machine. You should be comfortable with the command line before proceeding. If you're not UNIX-savvy and have only occasional needs, check out Ben Spink's Java-based FTP server Crush.]

NFS works by mounting exported file systems from other computers on the network. As you want to mount files from your own computer, you first have to export your own file system. NFS is a little bit difficult to set up; that's why I chose to do it with NFSManager. NFSManager is a nice little programme, it's shareware but fully functional, it only pops up messages, when you want to save your changes.

In NFSManager in the 'Exports' tab create a new export for your computer by clicking on 'Add'. For the 'Directory to export' enter / to be able to import any directory from your computer. In the 'Where to export' tab choose Clients and enter localhost, so only your own computer will be able to connect to this NFS export. Choosing World may be unwise because then everybody on the network and on the internet would be able to mount your exported hard drive.

In 'NFS export options' I choose to 'Treat' all users 'as user' ftp. Also tick 'Read only' and 'Export entire filesystem'. By closing the window you can save this export. Unfortunately you can't use NFSManager to mount this export because on reboot, the network drives are mounted before the export is created, which of course will not work :-(

There's two ways to automatically mount the export on reboot:

1) making an entry to /etc/rc
2) making an entry to /Library/StartupItems

I chose to do the latter and here is how:

In /Library/StartupItems create a new directory called NFSforFTPD. In this directory create two files: NFSforFTPD and StartupParameters.plist.

This is the contents of NFSforFTPD:

# Mounting NFS export from localhost for ftpd

. /etc/rc.common

ConsoleMessage "Activating ftpd directory structure"

mount_nfs -b -P localhost:/Users/joe/Movies /Users/ftp/pub/Movies/
And here is the contents of StartupParameters.plist:
Description = "NFSforFTPD";
Provides = ("NFSforFTPD");
OrderPreference = "Last";
Messages =
start = "Activating ftpd directory structure";
stop = "Deactivating ftpd directory structure";
What NFSforFTPD simply does is to mount (by the mount_nfs command) the export from your own computer and more specifically the 'Movies' directory of the user 'joe' into the 'Movies' directory which resides in the 'pub' directory of the ftp user. By using localhost you make sure that the NFS traffic is not going through the internet but remains on your computer. The -b option stands for 'Return an error if the server does not respond' and the -P option stands for 'Use secure ports' in the NFSManager import window.

If you want to add e.g. the MP3 collection of user john you would just create a new directory in /Users/ftp/pub e.g. Music and add the following line to NFSforFTPD
mount_nfs -b -P localhost:/Users/john/Music /Users/ftp/pub/Music/
Rather simple, eh?

There's some caveats, though:

1) After adding more mounts in NFSforFTPD, you must do a reboot or you must enter those mounts in the terminal. Depends on what you prefer :-)

2) Using NFSManager to create such mounts is unfortunately a bad idea as stated above and here's why: for a running computer this works and it works really nicely through a nice GUI, but after a reboot the mounts won't work because they are started before the export. And what's worse, OS X then turns the mountpoint directory into a link, meaning that when you try to isse a mount_nfs command later, be it through the terminal or NFSforFTPD, it simply won't work :-(

3) For some stupid reason the NFS export and mounts don't seem to work on my computer, which is on DSL, when I untag 'connect automatically' in the network prefs pane and can only get them to work by hand :-(

Other than that this setup seems to work fine.

I'm not quite sure, if all or any of the above is simple enough or even correct, so proceed at your own risk! Any suggestions or corrections are welcome! I'm especially interested in doing the whole thing in NFSManager, so maybe there's somebody out there who knows how to reverse the mount/export order, or generally how to do this more easily?
  • Currently 0.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (0 votes cast)

Offer more directories via anonymous FTP | 3 comments | Create New Account
Click here to return to the 'Offer more directories via anonymous FTP' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Mounts for portables
Authored by: serversurfer on Oct 07, '01 06:44:50PM

Is there any way to get NFSmounts to mount automatically when I (re)connect to the network? On a similar note, can I set up a mountlist that tries to mount a routing computer (e.g., and if that fails, attempts to mount a remote IP instead?

[ Reply to This | # ]
Wont mount NFS
Authored by: cpaden on Nov 13, '01 12:39:19PM
Hey, I followed the instructions to no avail. I am not too familiar with nfs so maybe you can help. when I try the mount_nfs command in terminal, I get
  mount_nfs: can't access /Volumes/Londres/MP3/: Permission denied

[ Reply to This | # ]
Wont mount NFS
Authored by: jeufeu on Apr 12, '04 05:29:23AM

You need to reboot your computer after making changes to your exports file.
Another way is to launch this command line from a terminal window:
sudo kill -s HUP `cat /var/run/`

[ Reply to This | # ]