psql shell with no password prompt

psql shell with no password prompt

am 27.07.2010 18:53:30 von Steve.Toutant

Message en plusieurs parties au format MIME
--=_alternative 005CC9EE8525776D_=
Content-Type: text/plain; charset="US-ASCII"

Hi,
I created several SQL that are automatically executed via windows task
scheduler, here is an example
psql -U "dbadmin" -d mydb -f D:\script.sql

It was running well until I changed the user (to open a session)
associated to these task.
The script prompt for a password for user dbadmin.
How to avoid that? I guess there is a config so dbadmin will "trust" this
new user....
Thanks for your help,
Steve
--=_alternative 005CC9EE8525776D_=
Content-Type: text/html; charset="US-ASCII"



Hi,

I created several SQL that are automatically
executed via windows task scheduler, here is an example


psql -U "dbadmin" -d mydb
-f D:\script.sql




It was running well until I changed
the user (to open a session) associated to these task.


The script prompt for a password for
user dbadmin.

How to avoid that? I guess there is a
config so dbadmin will "trust" this new user....

Thanks for your help,

Steve
--=_alternative 005CC9EE8525776D_=--

Re: psql shell with no password prompt

am 27.07.2010 19:17:08 von Kevin Grittner

wrote:

> The script prompt for a password for user dbadmin.
> How to avoid that? I guess there is a config so dbadmin will
> "trust" this new user....

You can use pg_hba.conf or pgpass:

http://www.postgresql.org/docs/current/interactive/auth-pg-h ba-conf.html

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

-Kevin

--
Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin

Re: psql shell with no password prompt

am 27.07.2010 20:16:09 von Steve.Toutant

Message en plusieurs parties au format MIME
--=_alternative 00645AF18525776D_=
Content-Type: text/plain; charset="US-ASCII"

Thanks Kevin,
Which of these 2 methods is the best practice?

It is working with pgpass.
But not yet with hba.conf
I tried this without success.
host all all 127.0.0.1/32 trust


steve




"Kevin Grittner"
27/07/2010 01:17 PM

A
,
cc

Objet
Re: [ADMIN] psql shell with no password prompt








wrote:

> The script prompt for a password for user dbadmin.
> How to avoid that? I guess there is a config so dbadmin will
> "trust" this new user....

You can use pg_hba.conf or pgpass:

http://www.postgresql.org/docs/current/interactive/auth-pg-h ba-conf.html

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

-Kevin




--=_alternative 00645AF18525776D_=
Content-Type: text/html; charset="US-ASCII"



Thanks Kevin,

Which of these 2 methods is the best
practice?




It is working with pgpass.

But not yet with hba.conf

I tried this without success.

host    all    
    all         127.0.0.1/32    
     trust






steve










"Kevin Grittner"
<Kevin.Grittner@wicourts.gov>

27/07/2010 01:17 PM







A

<Steve.Toutant@inspq.qc.ca>, <pgsql-admin@postgresql.org>

cc



Objet

Re: [ADMIN] psql shell with no password
prompt


















<Steve.Toutant@inspq.qc.ca> wrote:



> The script prompt for a password for user dbadmin.

> How to avoid that? I guess there is a config so dbadmin will

> "trust" this new user....



You can use pg_hba.conf or pgpass:



http://www.postgresql.org/docs/current/interactive/auth-pg-h ba-conf.html



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



-Kevin








--=_alternative 00645AF18525776D_=--

Re: psql shell with no password prompt

am 27.07.2010 20:24:04 von Joshua Drake

On Tue, 2010-07-27 at 14:16 -0400, Steve.Toutant@inspq.qc.ca wrote:
>
> Thanks Kevin,
> Which of these 2 methods is the best practice?
>
> It is working with pgpass.
> But not yet with hba.conf
> I tried this without success.
> host all all 127.0.0.1/32 trust
>
>
> steve

Best practice? Use .pgpass, not trust.

JD

--
PostgreSQL.org Major Contributor
Command Prompt, Inc: http://www.commandprompt.com/ - 509.416.6579
Consulting, Training, Support, Custom Development, Engineering
http://twitter.com/cmdpromptinc | http://identi.ca/commandprompt


--
Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin

Re: psql shell with no password prompt

am 27.07.2010 20:34:17 von Kevin Grittner

"Joshua D. Drake" wrote:

> Best practice? Use .pgpass, not trust.

I would take ident over either in Linux; but the OP is on Windows
and I don't know if that's an option or, if so, how safe it is.

-Kevin

--
Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin

Re: psql shell with no password prompt

am 27.07.2010 21:34:41 von Scott Marlowe

On Tue, Jul 27, 2010 at 12:16 PM, wrote:
>
> Thanks Kevin,
> Which of these 2 methods is the best practice?
>
> It is working with pgpass.
> But not yet with hba.conf
> I tried this without success.
> host =A0 =A0all =A0 =A0 =A0 =A0 all =A0 =A0 =A0 =A0 127.0.0.1/32 =A0 =A0 =
=A0 =A0 =A0trust

You have to reload / restart the pg service for that to take effect.
Note that will only affect incoming connections on the same machine.

--=20
Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin

Re: psql shell with no password prompt

am 27.07.2010 23:56:22 von Walter Willmertinger

--001636c5b0de68004e048c659219
Content-Type: text/plain; charset=ISO-8859-1

You can set user and password with environment variables (PGUSER and
PGPASSWORD) , also in a Windows batch or program.

SET PGPASSWORD=xxxyyyzzz
psql -U "dbadmin" -d mydb -f D:\script.sql



Regards

Walter


On Tue, Jul 27, 2010 at 6:53 PM, wrote:

>
> Hi,
> I created several SQL that are automatically executed via windows task
> scheduler, here is an example
> psql -U "dbadmin" -d mydb -f D:\script.sql
>
> It was running well until I changed the user (to open a session) associated
> to these task.
> The script prompt for a password for user dbadmin.
>
> How to avoid that? I guess there is a config so dbadmin will "trust" this
> new user....
>
> Thanks for your help,
>
> Steve
>
>

--001636c5b0de68004e048c659219
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

You can set user and password with environment variables (PGUSER and PGPASS=
WORD) , also in a Windows batch or program.


SET PGPASSWO=
RD=3Dxxxyyyzzz
psql -U "=
;dbadmin" -d mydb -f D:\script.sql
=A0




Regards

Walter<=
br>


On Tue, Jul 27, 2010 at 6:53 PM, dir=3D"ltr"><Steve.Toutant@=
inspq.qc.ca
>
wrote:
e=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">


Hi,

I created several SQL that are aut=
omatically
executed via windows task scheduler, here is an example


psql -U "dbadmin" -d myd=
b
-f D:\script.sql




It was running well until I change=
d
the user (to open a session) associated to these task.


The script prompt for a password f=
or
user dbadmin.

How to avoid that? I guess there is=
a
config so dbadmin will "trust" this new user....

Thanks for your help,

Steve

<=
/blockquote>



--001636c5b0de68004e048c659219--

Re: psql shell with no password prompt

am 28.07.2010 01:02:00 von Scott Marlowe

However, those are deprecated, and the .pgpass is considered the
preferred method.

On Tue, Jul 27, 2010 at 3:56 PM, Walter Willmertinger wrote:
> You can set user and password with environment variables (PGUSER and
> PGPASSWORD) , also in a Windows batch or program.
> SET PGPASSWORD=xxxyyyzzz
> psql -U "dbadmin" -d mydb -f D:\script.sql
>
>
>
> Regards
>
> Walter
>
>
> On Tue, Jul 27, 2010 at 6:53 PM, wrote:
>>
>> Hi,
>> I created several SQL that are automatically executed via windows task
>> scheduler, here is an example
>> psql -U "dbadmin" -d mydb -f D:\script.sql
>>
>> It was running well until I changed the user (to open a session)
>> associated to these task.
>> The script prompt for a password for user dbadmin.
>>
>> How to avoid that? I guess there is a config so dbadmin will "trust" this
>> new user....
>>
>> Thanks for your help,
>>
>> Steve
>



--
To understand recursion, one must first understand recursion.

--
Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin

Re: psql shell with no password prompt

am 28.07.2010 23:02:47 von Walter Willmertinger

--00032555b6469d1364048c78f024
Content-Type: text/plain; charset=ISO-8859-1

I hope the method with the environment variables will hold on.

For security reasons it is much better to use the variable method with
PGPASSWORD. I can set the environment hidden from any user by a program.
The .pgpass is readable for any admin, opposed to the statement in the docs:
"On Microsoft Windows, it is assumed that the file is stored in a directory
that is secure, so no special permissions check is made."

Regards
Walter


On Wed, Jul 28, 2010 at 1:02 AM, Scott Marlowe wrote:

> However, those are deprecated, and the .pgpass is considered the
> preferred method.
>
> On Tue, Jul 27, 2010 at 3:56 PM, Walter Willmertinger
> wrote:
> > You can set user and password with environment variables (PGUSER and
> > PGPASSWORD) , also in a Windows batch or program.
> > SET PGPASSWORD=xxxyyyzzz
> > psql -U "dbadmin" -d mydb -f D:\script.sql
> >
> >
> >
> > Regards
> >
> > Walter
> >
> >
> > On Tue, Jul 27, 2010 at 6:53 PM, wrote:
> >>
> >> Hi,
> >> I created several SQL that are automatically executed via windows task
> >> scheduler, here is an example
> >> psql -U "dbadmin" -d mydb -f D:\script.sql
> >>
> >> It was running well until I changed the user (to open a session)
> >> associated to these task.
> >> The script prompt for a password for user dbadmin.
> >>
> >> How to avoid that? I guess there is a config so dbadmin will "trust"
> this
> >> new user....
> >>
> >> Thanks for your help,
> >>
> >> Steve
> >
>
>
>
> --
> To understand recursion, one must first understand recursion.
>

--00032555b6469d1364048c78f024
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

ont-size: 13px; border-collapse: collapse; ">I hope the method with the env=
ironment variables will hold on.


For security reasons it=
is much better to use the variable method with PGPASSWORD. I can set the e=
nvironment hidden from any user by a program.

The .pgpass is readable for any admin, opposed to the statement in the=
docs: " px; line-height: 18px; ">On Microsoft Windows, it is assumed that the file =
is stored in a directory that is secure, so no special permissions check is=
made."


Regards
Walter



On Wed, Jul 28, 2010 at 1:02 AM, Scott M=
arlowe <sco=
tt.marlowe@gmail.com
>
wrote:
ote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex=
;">
However, those are deprecated, and the .pgpass is considered the

preferred method.



On Tue, Jul 27, 2010 at 3:56 PM, Walter Willmertinger < :willmis@gmail.com">willmis@gmail.com> wrote:

> You can set user and password with environment variables (PGUSER and r>
> PGPASSWORD) , also in a Windows batch or program.

> SET PGPASSWORD=3Dxxxyyyzzz

> psql -U "dbadmin" -d mydb -f D:\script.sql

>

>

>

> Regards

>

> Walter

>

>

> On Tue, Jul 27, 2010 at 6:53 PM, < nspq.qc.ca">Steve.Toutant@inspq.qc.ca> wrote:

>>

>> Hi,

>> I created several SQL that are automatically executed via windows =
task

>> scheduler, here is an example

>> psql -U "dbadmin" -d mydb -f D:\script.sql

>>

>> It was running well until I changed the user (to open a session) r>
>> associated to these task.

>> The script prompt for a password for user dbadmin.

>>

>> How to avoid that? I guess there is a config so dbadmin will "=
;trust" this

>> new user....

>>

>> Thanks for your help,

>>

>> Steve

>







--

To understand recursion, one must first understand recursion.




--00032555b6469d1364048c78f024--