psql prompts for user password despite PGPASSFILE var defined
Asked Answered
M

0

6

I have an environment variable PGPASSFILE declared pointing to the location of my .pgpass file.

>echo $PGPASSFILE
/somedir/.pgpass

As per this doc, the permission stamp of the file is proper to not expose the file to anyone else:

>ls -la /somedir
drwxr-xr-x 2 root root 4096 2014-06-25 17:40 .
drwxr-xr-x 6 root root 4096 2014-06-25 16:37 ..
-rw------- 1 root root  354 2014-06-25 16:43 .pgpass
-rw-r--r-- 1 root root   30 2014-06-25 16:37 .pgpass_path

The file looks about right:

  1 localhost:*:*:postgres:blabla
  2 localhost:*:somedb:somedb_master:blabla
  3 localhost:*:somedb:somedb_rw:blabla

However, when I try to invoke psql, it still prompts me for password:

>psql -h localhost -d somedb -U somedb_rw
Password for user somedb_rw:

The connection succeeds when I enter password but I shouldn't be prompted. Any idea what may be wrong? This is on Ubuntu 10.04 VM. On my Mac host, this same configuration works without prompting.

Marchant answered 25/6, 2014 at 22:0 Comment(4)
From this example, it looks like you have a .pgpass in a directory named .pgpass? So, /somedir/.pgpass/.pgpass? If so, I think your $PGPASSFILE var needs to be updated.Favourable
no, the var actually needs to point to the file, not the directory where it isMarchant
Exactly. Your echo shows /somedir/.pgpass, but then you do a ls -la /somedir/.pgpass and it shows a file owned by root with the same name.Favourable
Does this answer your question? postgresql: .pgpass not workingGuizot

© 2022 - 2024 — McMap. All rights reserved.