Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Keeping a password safe. (database / PostgreSQL)

by erix (Vicar)
on Jun 12, 2012 at 13:11 UTC ( #975797=note: print w/ replies, xml ) Need Help??


in reply to Keeping a password safe.

In the case of worries about a postgres database-password the following is possible to connect without password (linux, unixen):

1. Use a ~/.pgpass file, or a customised copy somewhere (e.g. you could use the name name "$HOME/.pg_$USER"), and reduce access to it with chmod 0600 (in fact, in won't work otherwise). (see [1])

2. Point environment variable PGPASSFILE to a customised .pgpass-like file).

3. To make matters easier, you can also set PGPORT, PGHOST, PGDATABASE (if they are different from the defaults, which are resp. 5432, /tmp, $USER).

psql et al (all clients based on libpq) can now connect via these variables (e.g. perl DBI will connect with the minimal dsn 'dbi:Pg:').

[1] pg manual: libpq-pgpass.html

[2] pg manual: client-authentication.html

UPDATE: thanks to moritz for reminding me to add PGDATABASE.


Comment on Re: Keeping a password safe. (database / PostgreSQL)
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://975797]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (9)
As of 2015-07-04 19:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (60 votes), past polls