pg.ddx.io pgsql-admin@postgresql.org mailing list archive
help / color / mirror / Atom feedHow to create a new user with password in commandline with no prompt for password
5+ messages / 2 participants
[nested] [flat]
* How to create a new user with password in commandline with no prompt for password
@ 2008-02-20 07:30 Rajiv Rajaian <rajiv.pgsql@gmail.com>
0 siblings, 1 reply; 5+ messages in thread
From: Rajiv Rajaian @ 2008-02-20 07:30 UTC (permalink / raw)
To: pgsql-admin
Hi all
Im using postgresql-8.0.3-1.
I need to create a new user in postgresql with password ..But it should not
prompt me to get the password ..ie only through command line I've to give
the password as input
Steps i had done are as follows
[root@g151 ~]# su postgres -c "createuser -A -d globus"
could not change directory to "/root"
CREATE USER
[root@g151 ~]# su globus -c "createdb rftDatabase"
could not change directory to "/root"
CREATE DATABASE
Also in /var/lib./pgsql/data/pg_hba.conf I ve added the entry as
host rftDatabase "globus" "172.16.10.151" 255.255.255.0 md5
Now when i tried to login to that database I got the following error
[root@g151 ~]# psql -U globus -d rftdatabase
psql: FATAL: Ident authentication failed for user "globus"
Also with password promt it was prompting password ..But I haven't created
the user with password
[root@g151 ~]# psql -U globus -d rftdatabase -W
Password:
Is it possible to create any new user in postgresql with password through
command line and with no prompt for password.??Is there any option in
Postgresql?
Also if I create a new user with su postgres -c "createuser -A -d
globus" .Will it set any default password while creating the user ??
Please I need some valuable suggestion s
Thanks /Regards
Rajiv
Project Associate
CARE,MIT,
Anna University
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: How to create a new user with password in commandline with no prompt for password
@ 2008-02-20 08:06 Shane Ambler <pgsql@Sheeky.Biz>
parent: Rajiv Rajaian <rajiv.pgsql@gmail.com>
0 siblings, 1 reply; 5+ messages in thread
From: Shane Ambler @ 2008-02-20 08:06 UTC (permalink / raw)
To: Rajiv Rajaian <rajiv.pgsql@gmail.com>; +Cc: pgsql-admin
Rajiv Rajaian wrote:
> Hi all
> Im using postgresql-8.0.3-1.
> I need to create a new user in postgresql with password ..But it should not
> prompt me to get the password ..ie only through command line I've to give
> the password as input
> Steps i had done are as follows
>
> [root@g151 ~]# su postgres -c "createuser -A -d globus"
> could not change directory to "/root"
> CREATE USER
For adding a user in SQL with a password you can use -
CREATE ROLE name WITH [ ENCRYPTED | UNENCRYPTED ] PASSWORD 'password';
Using that from the command line you can -
echo "CREATE ROLE name....." | psql -U postgres
to bypass the password prompt.
> [root@g151 ~]# su globus -c "createdb rftDatabase"
> could not change directory to "/root"
> CREATE DATABASE
>
>
> Also in /var/lib./pgsql/data/pg_hba.conf I ve added the entry as
>
> host rftDatabase "globus" "172.16.10.151" 255.255.255.0 md5
>
> Now when i tried to login to that database I got the following error
>
> [root@g151 ~]# psql -U globus -d rftdatabase
> psql: FATAL: Ident authentication failed for user "globus"
Your pg_hba.conf line above says a password must be used.
You can add a line with your no password account using trust to get past
that.
The other way around that is to use a .pgpass file in your local home
dir. http://www.postgresql.org/docs/8.3/interactive/libpq-pgpass.html
for more detail.
> Also with password promt it was prompting password ..But I haven't created
> the user with password
> [root@g151 ~]# psql -U globus -d rftdatabase -W
> Password:
>
>
> Is it possible to create any new user in postgresql with password through
> command line and with no prompt for password.??Is there any option in
> Postgresql?
> Also if I create a new user with su postgres -c "createuser -A -d
> globus" .Will it set any default password while creating the user ??
No password is stored unless you specify it.
As much as these are ways around your inconveniences, you should also
consider the security implications of using them.
--
Shane Ambler
pgSQL (at) Sheeky (dot) Biz
Get Sheeky @ http://Sheeky.Biz
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: How to create a new user with password in commandline with no prompt for password
@ 2008-02-20 09:15 Rajiv Rajaian <rajiv.pgsql@gmail.com>
parent: Shane Ambler <pgsql@Sheeky.Biz>
0 siblings, 1 reply; 5+ messages in thread
From: Rajiv Rajaian @ 2008-02-20 09:15 UTC (permalink / raw)
To: Shane Ambler <pgsql@sheeky.biz>; +Cc: pgsql-admin
Hi Shane
Thanks for u r suggestions
I tried to create user with the following command ..Im getting
authentication error for postgres user
[root@g151~]# echo "CREATE USER globus WITH PASSWORD 'globus' CREATEDB;" |
psql -U postgres
psql: FATAL: IDENT authentication failed for user "postgres"
> Get Sheeky @ http://Sheeky.Biz
>
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: How to create a new user with password in commandline with no prompt for password
@ 2008-02-20 10:19 Rajiv Rajaian <rajiv.pgsql@gmail.com>
parent: Rajiv Rajaian <rajiv.pgsql@gmail.com>
0 siblings, 1 reply; 5+ messages in thread
From: Rajiv Rajaian @ 2008-02-20 10:19 UTC (permalink / raw)
To: Vishal Arora <aroravishal22@hotmail.com>
Hi vishal
While running it as "root" user Im getting
[root@g151 ~]# echo "CREATE ROLE globus WITH PASSWORD 'globus' CREATEDB;" |
psql -U postgres
psql: FATAL: Ident authentication failed for user "postgres"
Also with "postgres" user getting the same error
[postgres@g151 ~]$ echo "CREATE ROLE globus WITH PASSWORD 'globus'
CREATEDB;" | psql -U postgres
psql: FATAL: database "postgres" does not exist
On Feb 20, 2008 3:43 PM, Vishal Arora <aroravishal22@hotmail.com> wrote:
>
> you have to be Postgres Super user to use this command. and instead of
> CREATE USER - use CREATE ROLE...
>
>
> ------------------------------
> Date: Wed, 20 Feb 2008 14:45:50 +0530
> From: rajiv.pgsql@gmail.com
> To: pgsql@sheeky.biz
> Subject: Re: [ADMIN] How to create a new user with password in commandline
> with no prompt for password
> CC: pgsql-admin@postgresql.org
>
>
> Hi Shane
> Thanks for u r suggestions
> I tried to create user with the following command ..Im getting
> authentication error for postgres user
>
> [root@g151~]# echo "CREATE USER globus WITH PASSWORD 'globus' CREATEDB;" |
> psql -U postgres
> psql: FATAL: IDENT authentication failed for user "postgres"
>
>
>
> Get Sheeky @ http://Sheeky.Biz <http://sheeky.biz/;
>
>
>
> ------------------------------
> It's about getting married. Click here! Try it!<http://ss1.richmedia.in/recurl.asp?pid=201;
>
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: How to create a new user with password in commandline with no prompt for password
@ 2008-02-20 11:11 Rajiv Rajaian <rajiv.pgsql@gmail.com>
parent: Rajiv Rajaian <rajiv.pgsql@gmail.com>
0 siblings, 0 replies; 5+ messages in thread
From: Rajiv Rajaian @ 2008-02-20 11:11 UTC (permalink / raw)
To: Vishal Arora <aroravishal22@hotmail.com>
Hi Vishal
Now I m able to create new user using command line
I ve created a database named 'postgres' for postgres user and I ve created
the new user in comand line
The steps I ve used
[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
Thanks to Vishal, Shane and pgsql-admin list
Thanks/Regards
Rajiv
Project Associate,
CARE,MIT,
Anna University
^ permalink raw reply [nested|flat] 5+ messages in thread
end of thread, other threads:[~2008-02-20 11:11 UTC | newest]
Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2008-02-20 07:30 How to create a new user with password in commandline with no prompt for password Rajiv Rajaian <rajiv.pgsql@gmail.com>
2008-02-20 08:06 ` Shane Ambler <pgsql@Sheeky.Biz>
2008-02-20 09:15 ` Rajiv Rajaian <rajiv.pgsql@gmail.com>
2008-02-20 10:19 ` Rajiv Rajaian <rajiv.pgsql@gmail.com>
2008-02-20 11:11 ` Rajiv Rajaian <rajiv.pgsql@gmail.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