Thread: psql password prompt

psql password prompt

From
Dmitri Priimak
Date:
Hi All.

There is one thing which somewhat annoys me, which is that psql always
prompts me for a password.
That makes it difficult for use in Makefile where I want to say 'make
build_db', which would run psql for
each stored procedure which needs to be updated. Is there a way to
specify that password somehow in a
command line like isql ( sybase cli client ) does?

--
Dmitri Priimak


Re: psql password prompt

From
Peter Wullinger
Date:
In epistula a Dmitri Priimak, die horaque Sat, Sep 25, 2004 at 09:48:54AM -0700:
> Hi All.
>
> There is one thing which somewhat annoys me, which is that psql always
> prompts me for a password.
> That makes it difficult for use in Makefile where I want to say 'make
> build_db', which would run psql for
> each stored procedure which needs to be updated.

In that case, I would dump all operations into an SQL script
and run psql once from that script, if possible.

Other options (ranging from totally insecure to more secure
than password authentication and from easy to complex in
implementation) are available, if you have administrative
control over the PostgreSQL-server:

- completely disable authentication (in $PG_DATA/pg_hba.conf)
- disable authentication for your machine only
- run the update commands on the same machine as PostgreSQL runs
  and set the Unix domain socket to "ident sameuser" authentication
- use kerberos authentication

Otherwise I do not know of any other possibility to resolve
your problem other than hacking psql and implementing the
desired parameter.

> Is there a way to
> specify that password somehow in a
> command line like isql ( sybase cli client ) does?

That would be truly poor idea. The command line of any process is
normally visible to every user on the system via the `ps' command:

== password.sh ==
#! /bin/sh
sleep 10
== password.sh ==

% sh password.sh & sleep 1; ps | grep password
 3233  p2  SN+    0:00,01 sh password.sh --password myPassword

Cheers,
    Peter

--
Wir leben in einer Welt, worin ein Narr viele Narren, aber ein weiser
Mann nur wenige Weise macht.
    -- Immanuel Kant

Re: psql password prompt

From
John DeSoi
Date:
On Sep 25, 2004, at 12:48 PM, Dmitri Priimak wrote:

> There is one thing which somewhat annoys me, which is that psql always
> prompts me for a password.
> That makes it difficult for use in Makefile where I want to say 'make
> build_db', which would run psql for
> each stored procedure which needs to be updated. Is there a way to
> specify that password somehow in a
> command line like isql ( sybase cli client ) does?

You should be able to leave out the password altogether if you setup a
.pgpass file in your home directory.

http://www.postgresql.org/docs/current/interactive/libpq-pgpass.html


Best,

John DeSoi, Ph.D.