.pgpass being ignored

Started by Stephen Raskualmost 13 years ago8 messagesgeneral
Jump to latest
#1Stephen Rasku
srasku@gmail.com

I am trying to write a script that will create and populate a
database. I don't want to enter a password every time so I want to
use a .pgpass file. It has the correct permissions:

$ ls -l $PGPASSFILE
-rw------- 1 Stephen staff 43 21 Jun 14:48 /Users/Stephen/.pgpass

However, when I call createdb, it fails:

$ createdb -h 192.168.1.4 -U postgres --no-password JobSearch
createdb: could not connect to database postgres: fe_sendauth: no
password supplied

This is the contents of my .pgpass file:

192.168.1.4:5432:DatabaseName:postgres:thisIsTheCorrectPassword

If I omit the --no-password option it will prompt me for a password
and the command will succeed. I am using 9.0.10 from MacPorts.

What am I doing wrong?

...Stephen

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

#2Ziggy Skalski
zskalski@afilias.info
In reply to: Stephen Rasku (#1)
Re: .pgpass being ignored

On 13-06-21 06:19 PM, Stephen Rasku wrote:

I am trying to write a script that will create and populate a
database. I don't want to enter a password every time so I want to
use a .pgpass file. It has the correct permissions:

$ ls -l $PGPASSFILE
-rw------- 1 Stephen staff 43 21 Jun 14:48 /Users/Stephen/.pgpass

However, when I call createdb, it fails:

$ createdb -h 192.168.1.4 -U postgres --no-password JobSearch
createdb: could not connect to database postgres: fe_sendauth: no
password supplied

This is the contents of my .pgpass file:

192.168.1.4:5432:DatabaseName:postgres:thisIsTheCorrectPassword

If I omit the --no-password option it will prompt me for a password
and the command will succeed. I am using 9.0.10 from MacPorts.

What am I doing wrong?

...Stephen

Hi,

Just going from a personal experience, have you tried to open the
.pgpass file in vi and made sure there's no trailing spaces in your
pgpass entry? That bit me once before :)

Ziggy

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

#3Rebecca Clarke
r.clarke83@gmail.com
In reply to: Ziggy Skalski (#2)
Re: .pgpass being ignored

I could be wrong, but shouldn't the owner of .pgpass be postgres?

On Mon, Jun 24, 2013 at 3:17 PM, Ziggy Skalski <zskalski@afilias.info>wrote:

Show quoted text

On 13-06-21 06:19 PM, Stephen Rasku wrote:

I am trying to write a script that will create and populate a
database. I don't want to enter a password every time so I want to
use a .pgpass file. It has the correct permissions:

$ ls -l $PGPASSFILE
-rw------- 1 Stephen staff 43 21 Jun 14:48 /Users/Stephen/.pgpass

However, when I call createdb, it fails:

$ createdb -h 192.168.1.4 -U postgres --no-password JobSearch
createdb: could not connect to database postgres: fe_sendauth: no
password supplied

This is the contents of my .pgpass file:

192.168.1.4:5432:DatabaseName:**postgres:**thisIsTheCorrectPassword

If I omit the --no-password option it will prompt me for a password
and the command will succeed. I am using 9.0.10 from MacPorts.

What am I doing wrong?

...Stephen

Hi,

Just going from a personal experience, have you tried to open the .pgpass
file in vi and made sure there's no trailing spaces in your pgpass entry?
That bit me once before :)

Ziggy

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/**mailpref/pgsql-general&lt;http://www.postgresql.org/mailpref/pgsql-general&gt;

#4Jan Wieck
JanWieck@Yahoo.com
In reply to: Rebecca Clarke (#3)
Re: .pgpass being ignored

On 06/24/13 10:24, Rebecca Clarke wrote:

I could be wrong, but shouldn't the owner of .pgpass be postgres?

The owner of ~/.pgpass is whoever owns ~ (the home directory of that user).

And ~/.pgpass must have permissions 0600 in order for libpq to actually
use it.

Jan

On Mon, Jun 24, 2013 at 3:17 PM, Ziggy Skalski <zskalski@afilias.info
<mailto:zskalski@afilias.info>> wrote:

On 13-06-21 06:19 PM, Stephen Rasku wrote:

I am trying to write a script that will create and populate a
database. I don't want to enter a password every time so I want to
use a .pgpass file. It has the correct permissions:

$ ls -l $PGPASSFILE
-rw------- 1 Stephen staff 43 21 Jun 14:48
/Users/Stephen/.pgpass

However, when I call createdb, it fails:

$ createdb -h 192.168.1.4 -U postgres --no-password JobSearch
createdb: could not connect to database postgres:
fe_sendauth: no
password supplied

This is the contents of my .pgpass file:

192.168.1.4:5432:DatabaseName:__postgres:__thisIsTheCorrectPassword

If I omit the --no-password option it will prompt me for a password
and the command will succeed. I am using 9.0.10 from MacPorts.

What am I doing wrong?

...Stephen

Hi,

Just going from a personal experience, have you tried to open the
.pgpass file in vi and made sure there's no trailing spaces in your
pgpass entry? That bit me once before :)

Ziggy

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org
<mailto:pgsql-general@postgresql.org>)
To make changes to your subscription:
http://www.postgresql.org/__mailpref/pgsql-general
<http://www.postgresql.org/mailpref/pgsql-general&gt;

--
Anyone who trades liberty for security deserves neither
liberty nor security. -- Benjamin Franklin

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

#5Frank Broniewski
brfr@metrico.lu
In reply to: Jan Wieck (#4)
Re: .pgpass being ignored

However, when I call createdb, it fails:

$ createdb -h 192.168.1.4 -U postgres --no-password JobSearch
createdb: could not connect to database postgres:
fe_sendauth: no
password supplied

Hi,

isn't your --no-password switch preventing this? I never use this switch
and my .pgpass is used by shell scripts and other programs ...

Frank

--
Frank BRONIEWSKI

METRICO s.� r.l.
g�om�tres
technologies d'information g�ographique
rue des Romains 36
L-5433 NIEDERDONVEN

t�l.: +352 26 74 94 - 28
fax.: +352 26 74 94 99
http://www.metrico.lu

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

#6Adrian Klaver
adrian.klaver@aklaver.com
In reply to: Frank Broniewski (#5)
Re: .pgpass being ignored

On 06/24/2013 11:36 PM, Frank Broniewski wrote:

However, when I call createdb, it fails:

$ createdb -h 192.168.1.4 -U postgres --no-password
JobSearch
createdb: could not connect to database postgres:
fe_sendauth: no
password supplied

Hi,

isn't your --no-password switch preventing this? I never use this switch
and my .pgpass is used by shell scripts and other programs ...

http://www.postgresql.org/docs/9.2/interactive/app-createdb.html

-w
--no-password
Never issue a password prompt. If the server requires password
authentication and a password is not available by other means such as a
.pgpass file, the connection attempt will fail. This option can be
useful in batch jobs and scripts where no user is present to enter a
password.

Frank

--
Adrian Klaver
adrian.klaver@gmail.com

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

#7Magnus Hagander
magnus@hagander.net
In reply to: Stephen Rasku (#1)
Re: .pgpass being ignored

On Sat, Jun 22, 2013 at 12:19 AM, Stephen Rasku <srasku@gmail.com> wrote:

I am trying to write a script that will create and populate a
database. I don't want to enter a password every time so I want to
use a .pgpass file. It has the correct permissions:

$ ls -l $PGPASSFILE
-rw------- 1 Stephen staff 43 21 Jun 14:48 /Users/Stephen/.pgpass

However, when I call createdb, it fails:

$ createdb -h 192.168.1.4 -U postgres --no-password JobSearch
createdb: could not connect to database postgres: fe_sendauth: no
password supplied

This is the contents of my .pgpass file:

192.168.1.4:5432:DatabaseName:postgres:thisIsTheCorrectPassword

If I omit the --no-password option it will prompt me for a password
and the command will succeed. I am using 9.0.10 from MacPorts.

What am I doing wrong?

From the error message, the failure is to connect to the database
"postgres". Your .pgpass only has an entry for database
"DatabaseName".

createdb will connect to "postgres" and issue the CREATE DATABASE
command there. You can change tihs with the parameter
--maintenance-db, but tat was added in 9.2 only. But even so, createdb
must connect to an *existing* database in order to issue the CREATE
DATABASE command, so you need a line in .pgpass for whichever
maintenance db you're using.

(also, you should really upgrade to 9.0.13, though that won't change
this specific case)

--
Magnus Hagander
Me: http://www.hagander.net/
Work: http://www.redpill-linpro.com/

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

#8Granthana Biswas
granthana.biswas@gmail.com
In reply to: Stephen Rasku (#1)
Re: .pgpass being ignored

In case someone is facing the same problem again, solution is to add * in
.pgpass in place of ip address.

--
View this message in context: http://postgresql.1045698.n5.nabble.com/pgpass-being-ignored-tp5760421p5815268.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.

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