Site Directories Protection: protdir Utility

The protdir utility is used to manage password protection of Web directories on domains through CLI. By using this utility, you can perform the following tasks:

Syntax

protdir <command> [<directory name>] [

<option_1> [<param>]

[<option_2> [<param>]]

…[<option_N> [<param>]]

]

Example

The following command line creates password-protected directory Protected_Dir in the /httpdocs directory on domain example.com, adds the password-protected directory user authorizeduser, and sets the user password to userpass.

# ./protdir --create Protected_Dir -domain example.com -add_user authorizeduser -passwd userpass

Commands

Command

Parameter

Description

Example

--create or -c

<directory name>

Creates a password protected directory on a domain. If the directory already exist on the domain, the command enables password protection of the directory.

Requires concomitant use of the -type option.

To create password-protected directory Protected_Dir in the /httpdocs directory on domain example.com:

# ./protdir --create Protected_Dir -domain example.com -type nonssl

or

# ./protdir -c Protected_Dir -domain example.com -type nonssl

--update or -u

<directory name>

Updates settings of a password-protected directory.

To set title "This directory is password protected" for the login dialog box to be displayed when users attempt to access password-protected directory /httpdocs/Protected_Dir:

# ./protdir --update Protected_Dir -domain example.com -title "This directory is password protected"

or

# ./protdir -u Protected_Dir -domain example.com -title "This directory is password protected"

--remove or -r

<directory name>

Deletes a password-protected directory.

To delete password-protected directory /httpdocs/Protected_Dir from domain example.com:

# ./protdir --remove Protected_Dir -domain example.com -type nonssl

or

# ./protdir -r Protected_Dir -domain example.com -type nonssl

--help or -h

 

Displays help on the use of the utility.

To see help on the use of the protdir utility:

# ./protdir -–help

or

# ./protdir -h

Options

Option

Parameter

Description

Example

-domain

<domain name>

Specifies the name of a domain to which a password-protected directory belongs.

Used with all commands, except the --help command.

To create the Protected_Sample protected URL on example.com:

# ./protdir -c Protected_Dir -domain example.com

-title

<string>

Specifies the title for the login dialog box to be displayed when users attempt to access a password-protected directory.

To set title "This directory is password protected" for the login dialog box to be displayed when users attempt to access password-protected directory /httpdocs/Protected_Dir:

# ./protdir -u Protected_Dir -domain example.com -title "This directory is password protected"

-type

nonssl | ssl | cgi

Specifies the location of a password directory in the domain root catalog:

  • nonssl - the /httpdocs directory
  • ssl - the /httpsdocs directory
  • cgi- the /cgi-bin directory

To create password-protected directory Protected_Dir in the /httpdocs/Protected directory on domain example.com:

# ./protdir -c Protected/Protected_Dir -domain example.com -type nonssl

-passwd

<password>

Specifies the password for accessing contents of a password-protected directory by a user.

See additional comments in the Note below the table.

To create user authorizeduser authorized to access contents of password-protected directory /httpdocs/Protected_Dir on domain example.com, set the user password to userpass and the password type to plain:

# ./protdir -u Protected_Dir -type nonssl -domain example.com -add_user authorizeduser -passwd userpass -passwd_type plain

-passwd_type

plain | encrypted

Specifies the type of the password for accessing contents of a password-protected directory by users.

See additional comments in the Note below the table.

-add_user

<login name>

Creates a password-protected directory user with the specified login name.

-update_user

<login name>

Updates settings of a password-protected directory user with the specified login name.

To change the user login name from authorizeduser to admin for the password-protected directory /httpdocs/Protected_Dir on domain example.com:

# ./protdir -u Protected_Dir -type nonssl -domain example.com -update_user authorizeduser -user_name admin

-user_name

<login name>

Sets a password-protected directory login name.

Used in conjunction with the -update_user option.

-remove_user

<login name>

Deletes a password-protected directory user with the specified login name.

To delete the user with login name authorizeduser for a password-protected directory /httpdocs/Protected_Dir on domain example.com:

# ./protdir -u Protected_Dir -type nonssl -domain example.com -remove_user authorizeduser

-dir_name

<directory name>

Sets a new name for a password-protected directory.

Used in conjunction with the -update_user option.

To set a new name /httpdocs/Protected_Archive for a password-protected directory /httpdocs/Protected_Dir on domain example.com:

# ./protdir -u Protected_Dir -type nonssl -domain example.com -dir_name Protected_Archive

Note: Use of this option is not recommended. Passing passwords through CLI as parameters of the -passwd option may potentially compromise the system's security as command line can be observed by other users of the system. It is more secure to pass passwords through the environment variables. You can transfer non-encrypted passwords by using environment variable PSA_PASSWORD while using single quotes to specify the empty values in the command line for the argument of the -passwd - -passwd_type options.
Similarly, you can transfer encrypted passwords through the environment variable PSA_CRYPTED_PASSWORD while using single quotes to specify the empty values in the command line for the argument of the -passwd and -passwd_type options.