psql shell with no password prompt

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"


<br><font size=2 face="sans-serif">Hi,</font>
<br><font size=2 face="sans-serif">I created several SQL that are automatically
executed via windows task scheduler, here is an example</font>
<br><font size=2 face="sans-serif">psql -U "dbadmin" -d mydb
-f D:\script.sql</font>
<br>
<br><font size=2 face="sans-serif">It was running well until I changed
the user (to open a session) associated to these task.</font>
<br><font size=2 face="sans-serif">The script prompt for a password for
user dbadmin.</font>
<p><font size=2 face="sans-serif">How to avoid that? I guess there is a
config so dbadmin will "trust" this new user....</font>
<p><font size=2 face="sans-serif">Thanks for your help,</font>
<p><font size=2 face="sans-serif">Steve</font>
--=_alternative 005CC9EE8525776D_=--
Steve.Toutant [ Di, 27 Juli 2010 18:53 ] [ ID #2045181 ]

Re: psql shell with no password prompt

<Steve.Toutant [at] 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

--
Sent via pgsql-admin mailing list (pgsql-admin [at] postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin
Kevin Grittner [ Di, 27 Juli 2010 19:17 ] [ ID #2045182 ]

Re: psql shell with no password prompt

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" <Kevin.Grittner [at] wicourts.gov>
27/07/2010 01:17 PM

A
<Steve.Toutant [at] inspq.qc.ca>, <pgsql-admin [at] postgresql.org>
cc

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








<Steve.Toutant [at] 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_=
Content-Type: text/html; charset="US-ASCII"


<br><font size=2 face="sans-serif">Thanks Kevin,</font>
<br><font size=2 face="sans-serif">Which of these 2 methods is the best
practice?</font>
<br>
<br><font size=2 face="sans-serif">It is working with pgpass.</font>
<br><font size=2 face="sans-serif">But not yet with hba.conf</font>
<br><font size=2 face="sans-serif">I tried this without success.</font>
<br><font size=2 face="Courier New">host    all    
    all         127.0.0.1/32    
     trust</font>
<br>
<br>
<br><font size=2 face="sans-serif">steve</font>
<p>
<br>
<br>
<br>
<table width=100%>
<tr valign=top>
<td width=40%><font size=1 face="sans-serif"><b>"Kevin Grittner"
<Kevin.Grittner [at] wicourts.gov></b> </font>
<p><font size=1 face="sans-serif">27/07/2010 01:17 PM</font>
<td width=59%>
<table width=100%>
<tr valign=top>
<td>
<div align=right><font size=1 face="sans-serif">A</font></div>
<td><font size=1 face="sans-serif"><Steve.Toutant [at] inspq.qc.ca>, <pgsql-admin [at] postgresql.org></font>
<tr valign=top>
<td>
<div align=right><font size=1 face="sans-serif">cc</font></div>
<td>
<tr valign=top>
<td>
<div align=right><font size=1 face="sans-serif">Objet</font></div>
<td><font size=1 face="sans-serif">Re: [ADMIN] psql shell with no password
prompt</font></table>
<br>
<table>
<tr valign=top>
<td>
<td></table>
<br></table>
<br>
<br>
<br>
<br>
<br><tt><font size=2><Steve.Toutant [at] inspq.qc.ca> wrote:<br>
<br>
> The script prompt for a password for user dbadmin.<br>
> How to avoid that? I guess there is a config so dbadmin will<br>
> "trust" this new user....<br>
<br>
You can use pg_hba.conf or pgpass:<br>
<br>
http://www.postgresql.org/docs/current/interactive/auth-pg-h ba-conf.html<br>
<br>
http://www.postgresql.org/docs/current/interactive/libpq-pgp ass.html<br>
<br>
-Kevin<br>
</font></tt>
<br>
<br>
<br>
--=_alternative 00645AF18525776D_=--
Steve.Toutant [ Di, 27 Juli 2010 20:16 ] [ ID #2045184 ]

Re: psql shell with no password prompt

On Tue, 2010-07-27 at 14:16 -0400, Steve.Toutant [at] 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 [at] postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin
Joshua Drake [ Di, 27 Juli 2010 20:24 ] [ ID #2045185 ]

Re: psql shell with no password prompt

"Joshua D. Drake" <jd [at] commandprompt.com> 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 [at] postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin
Kevin Grittner [ Di, 27 Juli 2010 20:34 ] [ ID #2045186 ]

Re: psql shell with no password prompt

On Tue, Jul 27, 2010 at 12:16 PM, <Steve.Toutant [at] 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 =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.

--
Sent via pgsql-admin mailing list (pgsql-admin [at] postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin
Scott Marlowe [ Di, 27 Juli 2010 21:34 ] [ ID #2045187 ]

Re: psql shell with no password prompt

--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, <Steve.Toutant [at] 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) 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.<div><br></div><div>SET PGPASSWO=
RD=3Dxxxyyyzzz</div><div><font size=3D"2" face=3D"sans-serif">psql -U "=
;dbadmin" -d mydb -f D:\script.sql</font>=A0<br>
<div><br></div><div><br></div><div><br clear=3D"all">Regards<br><br>Walter<=
br>
<br><br><div class=3D"gmail_quote">On Tue, Jul 27, 2010 at 6:53 PM, <span =
dir=3D"ltr"><<a href=3D"mailto:Steve.Toutant [at] inspq.qc.ca">Steve.Toutant [at] =
inspq.qc.ca</a>></span> wrote:<br><blockquote class=3D"gmail_quote" styl=
e=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

<br><font size=3D"2" face=3D"sans-serif">Hi,</font>
<br><font size=3D"2" face=3D"sans-serif">I created several SQL that are aut=
omatically
executed via windows task scheduler, here is an example</font>
<br><font size=3D"2" face=3D"sans-serif">psql -U "dbadmin" -d myd=
b
-f D:\script.sql</font>
<br>
<br><font size=3D"2" face=3D"sans-serif">It was running well until I change=
d
the user (to open a session) associated to these task.</font>
<br><font size=3D"2" face=3D"sans-serif">The script prompt for a password f=
or
user dbadmin.</font>
<p><font size=3D"2" face=3D"sans-serif">How to avoid that? I guess there is=
a
config so dbadmin will "trust" this new user....</font>
</p><p><font size=3D"2" face=3D"sans-serif">Thanks for your help,</font>
</p><p><font size=3D"2" face=3D"sans-serif">Steve</font></p><p></p><p></p><=
/blockquote></div><br></div></div>

--001636c5b0de68004e048c659219--
Walter Willmertinger [ Di, 27 Juli 2010 23:56 ] [ ID #2045191 ]

Re: psql shell with no password prompt

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

On Tue, Jul 27, 2010 at 3:56 PM, Walter Willmertinger <willmis [at] gmail.com> 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, <Steve.Toutant [at] 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)
>> 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 [at] postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin
Scott Marlowe [ Mi, 28 Juli 2010 01:02 ] [ ID #2045244 ]

Re: psql shell with no password prompt

--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 <scott.marlowe [at] gmail.com>wrote:

> However, those are deprecated, and the .pgpass is considered the
> preferred method.
>
> On Tue, Jul 27, 2010 at 3:56 PM, Walter Willmertinger <willmis [at] gmail.com>
> 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, <Steve.Toutant [at] 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)
> >> 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

<span class=3D"Apple-style-span" style=3D"font-family: arial, sans-serif; f=
ont-size: 13px; border-collapse: collapse; ">I hope the method with the env=
ironment variables will hold on.<div><br></div><div>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.</div>
<div>The .pgpass is readable for any admin, opposed to the statement in the=
docs: "<span style=3D"font-family: verdana, sans-serif; font-size: 12=
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."</span></div>
<div><br clear=3D"all">Regards</div></span>Walter<br>
<br><br><div class=3D"gmail_quote">On Wed, Jul 28, 2010 at 1:02 AM, Scott M=
arlowe <span dir=3D"ltr"><<a href=3D"mailto:scott.marlowe [at] gmail.com">sco=
tt.marlowe [at] gmail.com</a>></span> wrote:<br><blockquote class=3D"gmail_qu=
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<br>
preferred method.<br>
<div><div></div><div class=3D"h5"><br>
On Tue, Jul 27, 2010 at 3:56 PM, Walter Willmertinger <<a href=3D"mailto=
:willmis [at] gmail.com">willmis [at] gmail.com</a>> wrote:<br>
> You can set user and password with environment variables (PGUSER and<b=
r>
> PGPASSWORD) , also in a Windows batch or program.<br>
> SET PGPASSWORD=3Dxxxyyyzzz<br>
> psql -U "dbadmin" -d mydb -f D:\script.sql<br>
><br>
><br>
><br>
> Regards<br>
><br>
> Walter<br>
><br>
><br>
> On Tue, Jul 27, 2010 at 6:53 PM, <<a href=3D"mailto:Steve.Toutant [at] i=
nspq.qc.ca">Steve.Toutant [at] inspq.qc.ca</a>> wrote:<br>
>><br>
>> Hi,<br>
>> I created several SQL that are automatically executed via windows =
task<br>
>> scheduler, here is an example<br>
>> psql -U "dbadmin" -d mydb -f D:\script.sql<br>
>><br>
>> It was running well until I changed the user (to open a session)<b=
r>
>> associated to these task.<br>
>> The script prompt for a password for user dbadmin.<br>
>><br>
>> How to avoid that? I guess there is a config so dbadmin will "=
;trust" this<br>
>> new user....<br>
>><br>
>> Thanks for your help,<br>
>><br>
>> Steve<br>
><br>
<br>
<br>
<br>
</div></div><font color=3D"#888888">--<br>
To understand recursion, one must first understand recursion.<br>
</font></blockquote></div><br>

--00032555b6469d1364048c78f024--
Walter Willmertinger [ Mi, 28 Juli 2010 23:02 ] [ ID #2045247 ]
Datenbanken » gmane.comp.db.postgresql.admin » psql shell with no password prompt

Vorheriges Thema: postgresql-server-8.4.4-1PGDG.el5 - ERROR: could not write block503414 of temporary file: No space
Nächstes Thema: Raid Recommendation