fe_sendauth: no password supplied when connecting to remote PostgreSQL

2,030 views
Skip to first unread message

Eric Mortensen

unread,
Aug 12, 2014, 11:30:11 AM8/12/14
to sqitch...@googlegroups.com
I am trying out Sqitch and so far I really like it. I have managed to connect to a local database on my Mac OS X, but I am having trouble connecting to a remote database on a CentOS cluster. 

I have no trouble connecting with psql like this from  one Linux-box to another: 

>$ psql -h <host> -U <user> -d <database> 
Password for user <user>:
psql (9.4beta1)
Type "help" for help.

<database>=# \q  

However, when I run the following I get "no password supplied error":

$ sqitch -h <host> -u <user> -d <database> --engine pg status 

#On database db:pg://<user>@<host>/<database>
fe_sendauth: no password supplied
trace: Trace begun at /usr/local/lib64/perl5/DBI.pm line 683
trace: DBI::__ANON__(undef, undef) called at /usr/local/lib64/perl5/DBI.pm line 740
trace: DBI::connect('DBI', 'dbi:Pg:host=<host>;dbname=<database>', '<user>', undef, 'HASH(0x31108f0)') called at /usr/local/share/perl5/App/Sqitch/Engine/pg.pm line 119
trace: App::Sqitch::Engine::pg::__ANON__('App::Sqitch::Engine::pg=HASH(0x3045460)') called at /usr/local/share/perl5/App/Sqitch/Engine/pg.pm line 152
trace: eval {...} at /usr/local/share/perl5/App/Sqitch/Engine/pg.pm line 152
trace: App::Sqitch::Engine::pg::initialized('App::Sqitch::Engine::pg=HASH(0x3045460)') called at /usr/local/share/perl5/App/Sqitch/Command/status.pm line 108
trace: App::Sqitch::Command::status::catch {...} ('App::Sqitch::X=HASH(0x2d6e618)') called at /usr/local/share/perl5/Try/Tiny.pm line 104
trace: Try::Tiny::try('CODE(0x1263910)', 'Try::Tiny::Catch=REF(0x2c78a40)') called at /usr/local/share/perl5/App/Sqitch/Command/status.pm line 113
trace: App::Sqitch::Command::status::execute('App::Sqitch::Command::status=HASH(0x2dacfd0)') called at /usr/local/share/perl5/App/Sqitch.pm line 377
trace: App::Sqitch::try {...}  at /usr/local/share/perl5/Try/Tiny.pm line 76
trace: eval {...} at /usr/local/share/perl5/Try/Tiny.pm line 72
trace: Try::Tiny::try('CODE(0x2ce8b40)', 'Try::Tiny::Catch=REF(0x2a995a8)') called at /usr/local/share/perl5/App/Sqitch.pm line 397
trace: App::Sqitch::go('App::Sqitch') called at /usr/local/bin/sqitch line 17

It seems that it is the line with the DBI::connect call that refuses to supply the password. I no next to nothing about Perl, but It looks like the password is "undef" no matter what. I have created a $HOME/.pgpass file that works as it should with psql.

The Perl DBI version is 1.631, and sqitch is version 0.995.

Anybody experienced anything similar?

Thanks in advance for any help.

Regards
Eric Mortensen

 


David E. Wheeler

unread,
Aug 13, 2014, 12:11:47 AM8/13/14
to Eric Mortensen, sqitch...@googlegroups.com
On Aug 12, 2014, at 8:30 AM, Eric Mortensen <eric...@gmail.com> wrote:

> I have no trouble connecting with psql like this from one Linux-box to another:
>
> >$ psql -h <host> -U <user> -d <database>
> Password for user <user>:
> psql (9.4beta1)
> Type "help" for help.
>
> <database>=# \q
>
> However, when I run the following I get "no password supplied error":
>
> $ sqitch -h <host> -u <user> -d <database> --engine pg status
>
> #On database db:pg://<user>@<host>/<database>
> fe_sendauth: no password supplied

You supplied no password.

> It seems that it is the line with the DBI::connect call that refuses to supply the password. I no next to nothing about Perl, but It looks like the password is "undef" no matter what. I have created a $HOME/.pgpass file that works as it should with psql.

It should also work with Sqitch. In your example above you have typed in your password. Are you able to connect to the remote host in psql without having to type in a password? If not, then your ~/.pgpass is not configured correctly.

There are two other was to supply a password to PostgreSQL:

1. Set the PGPASSWORD environment variable:

PGPASSWORD=<pass> sqitch -h <host> -u <user> -d <database> --engine pg status

2. Put the password into the target URI, which is preferred to the -h, -u, and -d options anyway:

sqitch status db:pg://<user>:<pass>@<host>/<database>

Since you won’t generally want to put the password on the command-line, ~/.pgpass is the best way to go. But if you have to use a URI, you can save it in your configuration as described here:

http://theory.so/sqitch/2014/01/09/sqitch-on-target/

Best,

David

signature.asc

Eric Mortensen

unread,
Aug 13, 2014, 2:24:15 AM8/13/14
to sqitch...@googlegroups.com, eric...@gmail.com
Hi David

I got the PGPASSWORD env variable to work. Thank you. 

And again, sqitch works beautifully.

Regards,
Eric
Reply all
Reply to author
Forward
0 new messages