PostgreSQL Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsDatabasesPostgreSQL Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 15th, 2002, 06:45 AM
ggnanaraj ggnanaraj is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Location: Chennai, India
Posts: 69 ggnanaraj User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 m 55 sec
Reputation Power: 11
Password prompt in script ??

I have the following statement...

Code:
psql test -c "update d_conf_backup set name=to_char(now(), 'DDMONYYYYHH24MI')"


which was working perfectly well using 'trust' authentication.

However, now I have changed the database setting to 'md5' for encrypted password authentication.

Now, the above code fails with...

Quote:

Password:
psql: fe_sendauth: no password supplied



I tried passing the password in the above code using -U & -W but it does not work. Is any other option is available ?

Do give your valuable input.

Thanks.

Reply With Quote
  #2  
Old October 15th, 2002, 06:48 PM
Ted Striker Ted Striker is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2002
Posts: 409 Ted Striker User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 12
I think for using md5, you will have to setup postgres password and/or shadow files. Note that these are not the UNIX password and shadow files, but are a postgres specific version of thems separate from UNIX. Section 4.2.2 explains it in more detail:

http://www.postgresql.org/idocs/ind...th-methods.html

Did you also setup the user with encrypted password?


CREATE USER test WITH ENCRYPTED PASSWORD 'blah';

This user also referred to setting up md5 in the pg_hba.conf file:

http://dbforums.com/t322752.html

Last edited by Ted Striker : October 15th, 2002 at 06:51 PM.

Reply With Quote
  #3  
Old October 15th, 2002, 11:47 PM
ggnanaraj ggnanaraj is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Location: Chennai, India
Posts: 69 ggnanaraj User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 m 55 sec
Reputation Power: 11
Thanks for your reply. The info was very useful.

However, I'm sorry to have not been clear in my posting...

I'm able to connect using a password, ...

Quote:

postgres@sun051 pgsql]$ psql run
Password:
Welcome to psql, the PostgreSQL interactive terminal.

Type: \copyright for distribution terms
\h for help with SQL commands
\? for help on internal slash commands
\g or terminate with semicolon to execute query
\q to quit

run=#



however when I want to connect using a script to take backup, it fails with the error mentioned as there is no password supplied.

So, for this, I wonder if there is an option to pass a password in the script.

Best Regards.

Reply With Quote
  #4  
Old October 16th, 2002, 02:31 AM
Ted Striker Ted Striker is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2002
Posts: 409 Ted Striker User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 12
What error messages do you get when you use the -U & -W ?

Reply With Quote
  #5  
Old October 16th, 2002, 03:17 AM
ggnanaraj ggnanaraj is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Location: Chennai, India
Posts: 69 ggnanaraj User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 m 55 sec
Reputation Power: 11
Quote:
Originally posted by Ted Striker
What error messages do you get when you use the -U & -W ?


It still asks for password ...

Quote:

[postgres@sun051 pgsql]$ cat bk3.sh
psql dev -U postgres -W postgres -c "update d_conf_backup set name=to_char(now(), 'DDMONYYYYHH24MI')"
psql dev -U postgres -W postgres -t -c "select 'pg_dump dev > dev'||name||'.dmp' from d_conf_backup" > bk4.sh
chmod 755 bk4.sh
[postgres@sun051 pgsql]$ ./bk3.sh
psql: warning: extra option postgres ignored
Password:


Reply With Quote
  #6  
Old October 16th, 2002, 01:28 PM
Ted Striker Ted Striker is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2002
Posts: 409 Ted Striker User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 12
Looks like this is beyond me. Perhaps there is some kind of certificate or password file that needs to be set up.

Your best bet here would be to get on one of the Postgres mailing lists. Sometimes Tom Lane or Bruce Momjain will respond personally.

Reply With Quote
  #7  
Old October 17th, 2002, 01:40 PM
ultraslacker's Avatar
ultraslacker ultraslacker is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2002
Posts: 56 ultraslacker User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 12
You can pass a password in a script, it just isn't easy on 7.2 - I believe 7.3 will have a better fix for this by allowing you to specify a password file.

You can try env. vars PGUSER PGPASSWORD, although some os's will display that in ps - not a good idea for security.

Here's another method that will let the password be accepted from stdin.

http://groups.google.com/groups?q=p...guin.com&rnum=3
__________________
Casuistry Agnostic

Reply With Quote
  #8  
Old October 19th, 2002, 03:58 AM
ggnanaraj ggnanaraj is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Location: Chennai, India
Posts: 69 ggnanaraj User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 m 55 sec
Reputation Power: 11
Quote:
Originally posted by ultraslacker

Here's another method that will let the password be accepted from stdin.

http://groups.google.com/groups?q=p...guin.com&rnum=3


Thanks a mil ! This worked out.

Regards.

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesPostgreSQL Help > Password prompt in script ??

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap