Skip to content
Related Articles

Related Articles

htdigest command in Linux with examples
  • Last Updated : 26 Feb, 2019
GeeksforGeeks - Summer Carnival Banner

htdigest” command is used to create and update password file which is used by Apache HTTPD digest authentication. Basically, it stores usernames, realm, and password of HTTP users. Before sending any sensitive information such as online shopping transactions, it confirms identity of the users.

Syntax:

htdigest [-c] passwdfile realm username

Options:

  • [-c]: It is used to create a passwdfile, if this file does not exists then its created and if is already exists then that file is deleted and another file is recreated.
  • passwdfile: It contains username, realm, and password of the user.
  • realm: It is a string which is visible to the users to let them know which username and password to use.
  • Username It create or updates passwdfile. If this username does not exists then a new entry is added and if it exists then the password is changed.

Examples:

  • Command to create a new Apache password file and adding a new user:
    # htdigest -c httpd-pwd-file realm username 

    Example:



    Here, “httpd-pwd-file” is newly created password file which adds user gfg to the file, and “systemadmin” is the realm used here.

  • Command to see Apache password file format: It is the format of the context of the password file which is created by the ht_digest command in the text file. In order to see the password file format, you need to use “cat” command with the created password file. The format is:
    username:realm name:encrypted password

    Example:

    Here, httpd-pwd-file is the file created above.

  • Command to add another user to Apache password file:
    # htdigest httpd-pwd-file realm username

    Example:

    Here, user nidhi is added to httpd-pwd-file in realm author. Now, the format of the password will be:


    Here, password of two users are shown as the above httpd-pwd-file has two users now.

  • Command to change password of an user:
    # htdigest httpd-pwd-file realm username

    Example:



    Here, the password of the existing user can be changed.

  • Command to add users to multiple realms in password file:
    # htdigest httpd-pwd-file realm username

    Example:

    This command will add user nidhi to the existing httpd-pwd-file in the realm “systemadmin”.

    Note: There will be two password entries for user nidhi as it has different realms.

    Example:

  • Command to delete an user from Apache file: To delete an user from Apache file use “vi” command i.e, (vi name of password file).

Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.

My Personal Notes arrow_drop_up
Recommended Articles
Page :