Configuring Anonymous FTP Server by Command line

sábado, 7 de julho de 2012

1.Add user ftp to /etc/passwd, usually:

ftp:*:500:1:anonymous FTP:/home/ftp:/usr/bin/false
The password field should be *, the group membership should be guest, or, as in this example, other, and the login shell should be /usr/bin/false.
In this example, user ftp’s user ID is 500, and the anonymous FTP directory is /home/ftp.

2.Create the ftp home directory:
a.Create the ftp home directory that you referred to in the /etc/passwd file, usually:

# mkdir /home/ftp

b.Create the subdirectories usr/bin and /usr/lib under the ftp home directory, usually:

# cd /home/ftp
# mkdir -p usr/bin
3.Copy the ls command from /sbin to /home/ftp/usr/bin, and set the permissions on the command to execute only (mode 0111):

# cp /sbin/ls /home/ftp/usr/bin
# chmod u=x,g=x,o=x /home/ftp/usr/bin/ls
4.Set the owner of the /home/ftp/usr/bin and /home/ftp/usr directories to root, and set the permissions to read-execute (not writable) (mode 0555):

# chown root /home/ftp/usr/bin
# chmod u=rx,g=rx,o=rx /home/ftp/usr/bin # chown root /home/ftp/usr
# chmod u=rx,g=rx,o=rx /home/ftp/usr
5.Create the subdirectory etc under the ftp directory:

# cd /home/ftp
# mkdir etc
6.Copy /etc/passwd and /etc/group to /home/ftp/etc.
These files are required by the ls command, to display the owners of files and directories under /home/ftp.

# cp /etc/passwd /home/ftp/etc
# cp /etc/group /home/ftp/etc

7.In all entries in /home/ftp/etc/passwd, replace the password field with an asterisk (*), and delete the shell field, for example:

ftp:*:500:1:anonymous ftp:/home/ftp: tom:*:8996:20::/home/tom:
8.In all entries in /home/ftp/etc/group, replace the password field with an asterisk (*):

users:*:20:acb guest:*:21:ftp1

9.Change the owner of the files in /home/ftp/etc to root, and set the permissions to read only (mode 0444):

# chown root /home/ftp/etc
# chmod u=r,g=r,o=r /home/ftp/etc
10.Create a directory pub (for public) under /home/ftp, and change its owner to user ftp and its permissions to writable by all (mode 0777).
Anonymous FTP users can put files in this directory to make them available to other anonymous FTP users.

# mkdir /home/ftp/pub
# chown ftp /home/ftp/pub
# chmod u=rwx,g=rwx,o=rwx /home/ftp/pub
You can create other directories to provide separate categories, such as /home/ftp/draft and /home/ftp/final.

11.Create a directory dist (for distribution) under /home/ftp. Change its owner to root and its permissions to writable only by root (mode 0755).
Anonymous FTP users can read but not alter these directories.

# mkdir /home/ftp/dist
# chown root /home/ftp/dist
# chmod u=rwx,g=rx,o=rx /home/ftp/dist
12.Change the owner of user ftp’s home directory to root and the permissions to not writable (mode 0555):

# chown root /home/ftp
# chmod u=rx,g=rx,o=rx /home/ftp

This document is part from "HP Part Number '5992-4607'" documment.