This page in other versions: Unsupported versions: 7.0



pg_passwd — Manipulate the flat password file
pg_passwd filename


pg_passwd is a tool to manipulate the flat password file functionality of Postgres. This style of password authentication is not required in an installation, but is one of several supported security mechanisms.

Specify the password file in the same style of Ident authentication in $PGDATA/pg_hba.conf:

host  unv password passwd
where the above line allows access from using the passwords listed in $PGDATA/passwd. The format of the password file follows those of /etc/passwd and /etc/shadow. The first field is the user name, and the second field is the encrypted password. The rest is completely ignored. Thus the following three sample lines specify the same user and password pair:

Supply the password file to the pg_passwd command. In the case described above, after changing the working directory to PGDATA, the following command execution specify the new password for pg_guest:

       % pg_passwd passwd
        Username: pg_guest
        Re-enter password:
where the Password: and Re-enter password: prompts require the same password input which are not displayed on the terminal. The original password file is renamed to passwd.bk.

psql uses the -u option to invoke this style of authentication.

The following lines show the sample usage of the option:

% psql -h hyalos -u unv
Username: pg_guest
Welcome to the POSTGRESQL interactive sql monitor:
  Please read the file COPYRIGHT for copyright terms of POSTGRESQL
   type \? for help on slash commands
   type \q to quit
   type \g or terminate with semicolon to execute query
 You are currently connected to the database: unv

Perl5 authentication uses the new style of the like this:

$conn = Pg::connectdb("host=hyalos dbname=unv
                       user=pg_guest password=xxxxxxx");
For more details, refer to src/interfaces/perl5/

Pg{tcl,tk}sh authentication uses the pg_connect command with the -conninfo option thusly:

% set conn [pg_connect -conninfo \\
            "host=hyalos dbname=unv \\
             user=pg_guest password=xxxxxxx "]
You can list all of the keys for the option by executing the following command:
% puts [ pg_conndefaults]

Submit correction

If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group