pg.ddx.io pgsql-admin@postgresql.org mailing list archive
help / color / mirror / Atom feedafter initdb - Re: How to CREATEDB in commandline with no prompt for password
3+ messages / 2 participants
[nested] [flat]
* after initdb - Re: How to CREATEDB in commandline with no prompt for password
@ 2008-03-04 00:50 ` bwnabble <bwiese@cotse.com>
2008-03-05 03:43 ` Re: after initdb - Re: How to CREATEDB in commandline with no prompt for password Shane Ambler <pgsql@Sheeky.Biz>
1 sibling, 1 reply; 3+ messages in thread
From: bwnabble @ 2008-03-04 00:50 UTC (permalink / raw)
To: pgsql-admin
Rajiv Rajaian-2 wrote:
>
> [root@g151 ~]# su postgres -c "createdb postgres"
> could not change directory to "/root"
> CREATE DATABASE
> [root@g151 ~]# echo "CREATE USER globus WITH PASSWORD 'globus' CREATEDB;"
> |
> psql -U postgres -d postgres
> psql: FATAL: Ident authentication failed for user "postgres"
> [root@g151 ~]# su postgres -c "echo \"CREATE USER globus WITH PASSWORD
> 'globus' CREATEDB;\" | psql -U postgres -d postgres"
> could not change directory to "/root"
> CREATE USER
> [root@g151 ~]# su globus -c "createdb rftDatabase"
> could not change directory to "/root"
> CREATE DATABASE
>
Rajiv,
Did you have your METHODs set to "trust" in your "pg_hba.conf" file (in the
$PGDATA directory)?
My question is, similar to yours, is there a way to:
1) run "initdb" as user "postgres" on an empty $PGDATA directory to start
from scratch
2) change the METHODs in "$PGDATA/pg_hba.conf" from "trust" -> "password"
3) start the postgresql server
4) run "createdb mydb" with no prompt for a password? (as user root or
postgres?)
I can only perform step 4 (createdb mydb) when the default METHOD is "trust"
in pg_hba.conf and I'm wondering if is any way around it? I want to disable
"trust" for security purposes.
Must I use the METHOD "trust" first in order to create a user with
"createdb" privileges, and then change METHODs in pg_hba.conf from "trust"
to "password"?
--
View this message in context: http://www.nabble.com/How-to-create-a-new-user-with-password-in-commandline-with-no-prompt-for-passw...
Sent from the PostgreSQL - admin mailing list archive at Nabble.com.
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: after initdb - Re: How to CREATEDB in commandline with no prompt for password
2008-03-04 00:50 ` after initdb - Re: How to CREATEDB in commandline with no prompt for password bwnabble <bwiese@cotse.com>
@ 2008-03-05 03:43 ` Shane Ambler <pgsql@Sheeky.Biz>
0 siblings, 0 replies; 3+ messages in thread
From: Shane Ambler @ 2008-03-05 03:43 UTC (permalink / raw)
To: bwnabble <bwiese@cotse.com>; +Cc: pgsql-admin
bwnabble wrote:
>
> Did you have your METHODs set to "trust" in your "pg_hba.conf" file (in the
> $PGDATA directory)?
>
> My question is, similar to yours, is there a way to:
> 1) run "initdb" as user "postgres" on an empty $PGDATA directory to start
> from scratch
> 2) change the METHODs in "$PGDATA/pg_hba.conf" from "trust" -> "password"
> 3) start the postgresql server
> 4) run "createdb mydb" with no prompt for a password? (as user root or
> postgres?)
1 & 3 are standard CLI commands that can be scripted as well as anything
else you do on your system. (3 would be scripted already so that pg
starts with the system)
2 is a simple editing of a file that gets performed once after step 1.
You would only do steps 1-3 once on a system (maybe a few more if you
are repeating it as a learning experience)
cratedb on the other hand may be something that gets run every time a
new user gets added to your server.
If you are looking to automate step 4 then you bypass the password
prompt with a trust entry that is only for the machine or user that will
perform the operation. The other option is using a .pgpass file.
If you are at a point where you want to automate setting up a large
number of new systems and you don't know enough about *nix systems to
create these scripts yourself then you should take a few steps back and
learn more about *nix sysadmin before you move on.
--
Shane Ambler
pgSQL (at) Sheeky (dot) Biz
Get Sheeky @ http://Sheeky.Biz
^ permalink raw reply [nested|flat] 3+ messages in thread
* after initdb - Re: How to CREATEDB in commandline with no prompt for password
@ 2008-03-04 02:28 ` bwnabble <bwiese@cotse.com>
1 sibling, 0 replies; 3+ messages in thread
From: bwnabble @ 2008-03-04 02:28 UTC (permalink / raw)
To: pgsql-admin
Rajiv Rajaian-2 wrote:
>
> [root@g151 ~]# su postgres -c "createdb postgres"
> could not change directory to "/root"
> CREATE DATABASE
> [root@g151 ~]# echo "CREATE USER globus WITH PASSWORD 'globus' CREATEDB;"
> |
> psql -U postgres -d postgres
> psql: FATAL: Ident authentication failed for user "postgres"
> [root@g151 ~]# su postgres -c "echo \"CREATE USER globus WITH PASSWORD
> 'globus' CREATEDB;\" | psql -U postgres -d postgres"
> could not change directory to "/root"
> CREATE USER
> [root@g151 ~]# su globus -c "createdb rftDatabase"
> could not change directory to "/root"
> CREATE DATABASE
>
Rajiv,
Did you have your METHODs set to "trust" in your "pg_hba.conf" file (in the
$PGDATA directory)?
My question is, similar to yours, is there a way to:
1) run "initdb" as user "postgres" on an empty $PGDATA directory to start
from scratch
2) change the METHODs in "$PGDATA/pg_hba.conf" from "trust" -> "password"
3) start the postgresql server
4) run "createdb mydb" with no prompt for a password? (as user root or
postgres?)
I can only perform step 4 (createdb mydb) when the default METHOD is "trust"
in pg_hba.conf and I'm wondering if is any way around it? I want to disable
"trust" for security purposes.
Must I use the METHOD "trust" first in order to create a user with
"createdb" privileges, and then change METHODs in pg_hba.conf from "trust"
to "password"?
--
View this message in context: http://www.nabble.com/How-to-create-a-new-user-with-password-in-commandline-with-no-prompt-for-passw...
Sent from the PostgreSQL - admin mailing list archive at Nabble.com.
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2008-03-05 03:43 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2008-03-04 00:50 ` bwnabble <bwiese@cotse.com>
2008-03-05 03:43 ` Shane Ambler <pgsql@Sheeky.Biz>
2008-03-04 02:28 ` bwnabble <bwiese@cotse.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox