Using ncftpd_passwd

The ncftpd_passwd utility program is used to create and modify NcFTPd Password Databases.  These databases are not regular text files like /etc/passwd, so a separate program is needed to manage them. The reason the files are in a binary format instead of human-readable format is because one of the advantages of using a file other than /etc/passwd is for performance -- an indexed database file is very efficient to read, while the /etc/passwd file must be scanned sequentially.  A database file can handle a large number of users without any noticeable performance degradation.

The files themselves are required to be owned by root and have mode 0600 (no read or write permission for group nor public).  This is required because the databases contain the encrypted password.  Having the encrypted password publicly available can be a security risk, which is why most modern UNIX systems have moved the encrypted passwords out of the /etc/passwd file into a separate file (often called the shadow password file).

You can still use ncftpd_passwd as non-root, but NcFTPd will not use password database files until they conform to the requirements listed above.

Creating and removing databases
To create a database you simply use the utility with the add user operation described below.  The database file will be created for you automatically if it did not exist.  To delete a database, you can simply remove it with /bin/rm.

Record format
The user entries are identical to the lines in the /etc/passwd file with one exception: the group field is a comma-delimited list of group IDs.  Therefore, the records look like this: Example: This user has user ID 500, home directory of /home/mgleason, primary group ID of 600, and membership in supplementary group IDs 700, 701, and 702.

Important:

Adding users
To add a user, run the program specifying the database file with the -f flag, and the complete user record specified by the -a flag.  Since the user record may have whitespace in it, use your shell's quote characters appropriately.

Example 1:  Add the mgleason user above, into a database named /usr/local/etc/ncftpd/pwdb/passwd.db.

It is inconvenient to use some other program to create the encrypted password based off of the cleartext password, so you can use the -c flag to tell the utility to encrypt the contents of the password field for you before adding the record.

Example 2:  Add the mgleason user above, setting the password to secret.

If you want to create a user whose user ID is identical to an existing user in the /etc/passwd file, you may use that user's name instead of manually look up the user ID. Similarly, you may substitute group names for group IDs and the utility will look them up for you.

Example 3:  Add the mgleason user above, with user and group name replacement.

Changing users
Modifying a user entry is the same as adding a new one, except you need to use the update flag (-u), instead of the add flag (-a).

Example: Change the password for mgleason to myxlplxx (using the -c flag also).

Querying users
To print the record for a user, specify the user name with the -q flag along with the database.

Example: Query mgleason's record.

Deleting users
To remove a user's record, specify the user name with the -d flag along with the database.

Example:  Delete mgleason's record.

Printing the entire database
You may use the export flag (-e) to convert a database into a textual format.

Example:  Dump the entire passwd.db database.

Importing records
You can add records in batch mode by creating an import file and using the import flag (-i).  You can also use the -c flag and user name and group name replacement when you import the records.

Example:

Importing the /etc/passwd file
You may elect to not use the /etc/passwd at all in favor of using just password databases, but you may want to load all the users from it into a database.  When you use the special -I flag, the /etc/passwd file is imported.  The special treatment is that the encrypted passwords are taken from the shadow password file (if needed), and the group field is created from the /etc/group file.

Example:

Tips
Up
NcFTPd Home