6

I'm using Ubuntu 12.04 LTS on my developer machine and just realized that psql stores passwords in '~/.pgpass'. Furthermore this file is unencrypted. So anyone who has super user rights (i.e. is in group sudo) can access this file and read stored passwords. That's the worst case it could be.

Instead I'm wondering that psql does not ask for a password (just modified a pg_hba.conf on a postgresql server) and began to doubt about my administration skills.

The documentation just tells us how to create the file and how it should look like.. I want to disable this file as soon as possible. But how?

NO SOLUTION

The problem is pgadmin creates this file when I want to store my passwords. It is a GUI and to use a GUI I'm already logged in and mostly the window manager has something like a keyring that is decrypted when I log in. It would be wonderful if pgadmin could use this but as discussed in the answer: it's a feature request for pgadmin.

0

1 Answer 1

9

Delete it. .pgpass is just a file. Enter the passwords on the command line if you don't want to store them. psql will never create or modify .pgpass, so you must've set it up yourself.

It makes no sense to store .pgpass encrypted; you'd need a password to decrypt it, and the whole point of .pgpass is for automating password logins.

The solution here is don't use a .pgpass file if you don't really need the passwordless login and aren't willing to accept the security compromises it imposes. Since it sounds like your .pgpass was created by PgAdmin-III, tell it not to save passwords and it won't create .pgpass. It gave you a big warning the first time you told it to save a password, telling you that it would store the password in clear text, for exactly this reason.

If you need strong and secure passwordless logins, use Kerberos / GSSAPI.

That said, anyone who has super-user rights can get your passwords no matter what you do. They can capture your typing with a keylogger. They can modify libpq to save the passwords to a file as they're entered. Lots of options. If you don't trust the superuser(s) on your machine, find somewhere else to work from, because you've already lost.

5
  • I have not created such file. May be pgadmin creates one. Thanks for your help. Then my next question is how to store passwords encrypted for pgadmin :)
    – iRaS
    Jun 7, 2013 at 14:12
  • 1
    @iRaS Ah, you didn't mention PgAdmin-III. Yes, it might. As far as I know it doesn't have any such support. Either store passwords or don't store passwords. Also, see updated answer. Jun 8, 2013 at 1:35
  • I trust superusers on my machine (as I'm the only one and I'm not schizophrenic). Lets say my notebook gets lost and someone starts a live linux stick. Then they are su and can access plain text files but can't access my keyboard while I'm writing.
    – iRaS
    Jun 10, 2013 at 6:47
  • @iRaS Yep, fair point, and one for which a .pgpass encrypted with a single common password might be useful. That would be a "please submit a patch" feature, though, and I'm not sure you'd get much interest from people, since the usual solution is not to save passwords if you don't want passwords saved. Jun 10, 2013 at 6:50
  • 1
    PgAdmin creates that file and it warns you when it does so. The warning even explicitly states that it is a plain file. Just for the record.
    – don.joey
    Jun 10, 2013 at 8:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .