Mac OS X Unleashed

Mac OS X Unleashed

By John Ray and William C. Ray

Setting Up Anonymous FTP

As you have seen, setting up the FTP server to allow real users to have FTP access is not difficult. Setting up the FTP server to allow anonymous FTP takes some work. Be warned that setting up anonymous FTP makes your machine vulnerable to yet more attacks. For whatever reason, you might have a need to conveniently distribute or receive files. An anonymous FTP server can provide an easy cross-platform way to accomplish those goals.

To set up an anonymous FTP site, do the following:

  1. Create an ftp user in the NetInfo database. Follow the pattern of one of the generic users, such as user unknown. You might start by duplicating the unknown user and editing the duplicate user. Create your ftp user with the basic parameters shown in Table 25.2.

    Table 25.2. Basic Parameters for an ftp User

    Property Value
    name ftp
    realname <some generic reference to ftp>
    uid <some unused uid number>
    passwd *
    home <some suitable location>
    shell /dev/null
    gid <some unused gid number>
    change 0
    expire 0
    Figure 25.2 shows the values we used for our ftp user.
    25fig02.jpg

    Figure 25.2 Here is how we chose to create our ftp user, as seen in the NetInfo Manager.

  2. Create an ftp group in the NetInfo database. Make sure that you assign the ftp group the same gid that you indicated for the ftp user.
  3. Create a home directory for user ftp. Make sure that you create the directory that you specified in the NetInfo database. The directory should be owned by root and have permissions 555.
  4. Create a ~ftp/bin directory, owned by root with permissions 555.
  5. Copy the system's /bin/ls to ~ftp/bin/.
  6. Create ~ftp/usr/lib. Each of those directories should be owned by root with permissions 555.
  7. Copy the system's /usr/lib/dyld to ~ftp/usr/lib. This is one of the files that helps ls function properly in this chrooted environment.
  8. Copy the system's /usr/lib/libSystem.B.dylib to ~ftp/usr/lib. This is another file that helps ls function properly in the chrooted environment.
  9. Create ~ftp/System/Library/Frameworks/System.framework/Versions/B. Each of those directories should be owned by root with permissions 555.
  10. Copy the system's /System/Library/Frameworks/System.framework/Versions/B/System to ~ftp/System/Library/Frameworks/System.framework/Versions/B. This is another file that helps ls function properly in the chrooted environment.
  11. Create a ~ftp/pub directory where files could be stored for download. Recommended ownership of this directory includes some user and group ftp or user root. Typical permissions for this directory are 755.
  12. If you also want to make a drop location where files could be uploaded, create ~ftp/incoming, owned by root. Recommended permissions include 753, 733, 1733, 3773 or 777. You could also create ~ftp/incoming with permissions 751 and subdirectories that are used as the drop locations with any of the recommended drop-off permissions.

If you decide to allow anonymous FTP, make sure that you regularly check the anonymous FTP area and your logs for any unusual activity. In addition, regularly check Apple's Web site for any updates for OS X that include ftp updates. Security holes are regularly found in ftpd and regularly fixed.

For your convenience, we include a listing of our ftp user's home directory:

[localhost:/Users] root# ls -lRaF ftp

     total 0
     dr-xr-xr-x   7 root  wheel  194 May  8 14:59 ./
     drwxr-xr-x  12 root  wheel  364 May 10 14:24 ../
     dr-xr-xr-x   3 root  wheel   58 May  8 13:28 System/
     dr-xr-xr-x   3 root  wheel   58 May  8 13:22 bin/
     drwxr-x-wx   2 root  wheel   24 May 10 14:32 incoming/
     drwxr-xr-x   2 root  wheel   24 May  8 15:01 pub/
     dr-xr-xr-x   3 root  wheel   58 May  8 13:22 usr/

     ftp/System:
     total 0
     dr-xr-xr-x  3 root  wheel   58 May  8 13:28 ./
     dr-xr-xr-x  7 root  wheel  194 May  8 14:59 ../
     dr-xr-xr-x  3 root  wheel   58 May  8 13:28 Library/

     ftp/System/Library:
     total 0
     dr-xr-xr-x  3 root  wheel  58 May  8 13:28 ./
     dr-xr-xr-x  3 root  wheel  58 May  8 13:28 ../
     dr-xr-xr-x  3 root  wheel  58 May  8 13:29 Frameworks/

     ftp/System/Library/Frameworks:
     total 0
     dr-xr-xr-x  3 root  wheel  58 May  8 13:29 ./
     dr-xr-xr-x  3 root  wheel  58 May  8 13:28 ../
     dr-xr-xr-x  3 root  wheel  58 May  8 13:30 System.framework/

     ftp/System/Library/Frameworks/System.framework:
     total 0
     dr-xr-xr-x  3 root  wheel  58 May  8 13:30 ./
     dr-xr-xr-x  3 root  wheel  58 May  8 13:29 ../
     dr-xr-xr-x  3 root  wheel  58 May  8 13:31 Versions/

     ftp/System/Library/Frameworks/System.framework/Versions:
     total 0
     dr-xr-xr-x  3 root  wheel  58 May  8 13:31 ./
     dr-xr-xr-x  3 root  wheel  58 May  8 13:30 ../
     dr-xr-xr-x  3 root  wheel  58 May  8 13:35 B/

     ftp/System/Library/Frameworks/System.framework/Versions/B:
     total 2464
     dr-xr-xr-x  3 root  wheel       58 May  8 13:35 ./
     dr-xr-xr-x  3 root  wheel       58 May  8 13:31 ../
     -r-xr-xr-x  1 root  wheel  1260748 May  8 13:35 System*

     ftp/bin:
     total 56
     dr-xr-xr-x  3 root  wheel     58 May  8 13:22 ./
     dr-xr-xr-x  7 root  wheel    194 May  8 14:59 ../
     -r-xr-xr-x  1 root  wheel  26984 May  8 13:22 ls*

     ftp/incoming:
     total 0
     drwxr-x-wx  2 root  wheel   24 May 10 14:32 ./
     dr-xr-xr-x  7 root  wheel  194 May  8 14:59 ../

     ftp/pub:
     total 0
     drwxr-xr-x  2 root  wheel   24 May  8 15:01 ./
     dr-xr-xr-x  7 root  wheel  194 May  8 14:59 ../

     ftp/usr:
     total 0
     dr-xr-xr-x  3 root  wheel   58 May  8 13:22 ./
     dr-xr-xr-x  7 root  wheel  194 May  8 14:59 ../
     dr-xr-xr-x  3 root  wheel   58 May  8 13:26 lib/

     ftp/usr/lib:
     total 640
     dr-xr-xr-x  3 root  wheel      58 May  8 13:26 ./
     dr-xr-xr-x  3 root  wheel      58 May  8 13:22 ../
     -r-xr-xr-x  1 root  wheel   327528 May  8 13:26 dyld*
     -r-xr-xr-x  1 root  wheel  1260748 May 11 13:25 libSystem.B.dylib*

For additional thoughts on anonymous FTP configuration, you might want to check these Web sites:

CERT Coordination Center Tech Tips http://www.cert.org/tech_tips/
WU-FTPD Resource Center's Related Documents link http://www.landfield.com/wu-ftpd/
AppleCare Tech Info Library http://til.info.apple.com

Share ThisShare This

Informit Network