supplying password to psql on command line?

Started by Stan Letovskyover 23 years ago8 messagesgeneral
Jump to latest
#1Stan Letovsky
stan@morgan.harvard.edu

Is this possible? The documentation is silent in this point. SYBASE
isql allows this by flag or environment variable.

Cheers, -Stan

#2Andrew Sullivan
andrew@libertyrms.info
In reply to: Stan Letovsky (#1)
Re: supplying password to psql on command line?

On Thu, Oct 24, 2002 at 10:59:10AM -0400, Stan Letovsky wrote:

Is this possible? The documentation is silent in this point. SYBASE
isql allows this by flag or environment variable.

Try the environment variable PGPASSWORD.

A

-- 
----
Andrew Sullivan                         204-4141 Yonge Street
Liberty RMS                           Toronto, Ontario Canada
<andrew@libertyrms.info>                              M2P 2A8
                                         +1 416 646 3304 x110
#3Christoph Dalitz
christoph.dalitz@hs-niederrhein.de
In reply to: Andrew Sullivan (#2)
Re: supplying password to psql on command line?

Date: Thu, 24 Oct 2002 10:59:10 -0400 (EDT)
From: Stan Letovsky <stan@morgan.harvard.edu>

Is this possible? The documentation is silent in this point. SYBASE
isql allows this by flag or environment variable.

Use the environment variable PGPASSWORD.

Christoph Dalitz

#4Medi Montaseri
medi.montaseri@intransa.com
In reply to: Stan Letovsky (#1)
Re: supplying password to psql on command line?

I think Font ends are moving away from this approach as others can see
your supplied
passwd by a simple ps(1) command.

Stan Letovsky wrote:

Show quoted text

Is this possible? The documentation is silent in this point. SYBASE
isql allows this by flag or environment variable.

Cheers, -Stan

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

#5Christoph Dalitz
christoph.dalitz@hs-niederrhein.de
In reply to: Medi Montaseri (#4)
Re: supplying password to psql on command line?

Date: Mon, 28 Oct 2002 10:56:32 -0800
From: Medi Montaseri <medi.montaseri@intransa.com>

I think Font ends are moving away from this approach as others can see
your supplied
passwd by a simple ps(1) command.

There used to be a program "hide.c" available from the oracle website,
which made this impossible. Unfortunately I can no longer find it.

A simpler approach however is to supply the password from stdin.
With Oracle's sqlplus this works as follows:

#!/bin/sh

sqlplus <<EOF
userid/password@tnasalias
/* SQL commands */
EOF

Unfortunately this does *not* work with psql because for some strange reason
psql does not read the password from stdin.

Christoph Dalitz

#6Christoph Dalitz
christoph.dalitz@hs-niederrhein.de
In reply to: Christoph Dalitz (#5)
Re: supplying password to psql on command line?

I think Font ends are moving away from this approach as others can see
your supplied
passwd by a simple ps(1) command.

There used to be a program "hide.c" available from the oracle website,
which made this impossible. Unfortunately I can no longer find it.

Found it here:
ftp://ftp.usg.edu/pub/oracle/security/hideargs/

Christoph Dalitz

#7Alvaro Herrera
alvherre@dcc.uchile.cl
In reply to: Christoph Dalitz (#5)
Re: supplying password to psql on command line?

On Tue, Oct 29, 2002 at 08:52:12AM +0100, Christoph Dalitz wrote:

Date: Mon, 28 Oct 2002 10:56:32 -0800
From: Medi Montaseri <medi.montaseri@intransa.com>

I think Font ends are moving away from this approach as others can see
your supplied
passwd by a simple ps(1) command.

Unfortunately this does *not* work with psql because for some strange reason
psql does not read the password from stdin.

You can always use PGPASSWORD. And for those of you that find that
envvar insecure or cumbersome, there's a new ~/.pgpass where you can
store passwords in 7.3.

--
Alvaro Herrera (<alvherre[a]dcc.uchile.cl>)
Y dijo Dios: "Que sea Satan�s, para que la gente no me culpe de todo a m�."
"Y que hayan abogados, para que la gente no culpe de todo a Satan�s"

#8Bruce Momjian
bruce@momjian.us
In reply to: Christoph Dalitz (#5)
Re: supplying password to psql on command line?

Christoph Dalitz wrote:

Date: Mon, 28 Oct 2002 10:56:32 -0800
From: Medi Montaseri <medi.montaseri@intransa.com>

I think Font ends are moving away from this approach as others can see
your supplied
passwd by a simple ps(1) command.

There used to be a program "hide.c" available from the oracle website,
which made this impossible. Unfortunately I can no longer find it.

A simpler approach however is to supply the password from stdin.
With Oracle's sqlplus this works as follows:

#!/bin/sh

sqlplus <<EOF
userid/password@tnasalias
/* SQL commands */
EOF

Unfortunately this does *not* work with psql because for some strange reason
psql does not read the password from stdin.

psql will read the password from stdin if there is no controlling
terminal on /dev/tty.

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073