Thread: Authorise root as postgres
Hi, Hope this simple question has a simple solution: How can I authorise root the same previliage as postgres? My postgres is password protected, I want to use 'psql -U postgres' as a root without specifying password every time, or for a certain group of users. How can I do that? I've been banning my head on the walls in finding a way to achieve it. Still can't find a way to do it with indent, md5 or even passwords authentication. Please help. Thanks a lot! Tong
On Sun, Nov 17, 2002 at 07:06:40PM +0000, * Tong * wrote: > My postgres is password protected, I want to use 'psql -U postgres' as a > root without specifying password every time, or for a certain group of > users. How can I do that? I've been banning my head on the walls in > finding a way to achieve it. Still can't find a way to do it with > indent, md5 or even passwords authentication. Please help. You can use the PGPASSWORD environment variable, or ~/.pgpass if 7.3. -- Alvaro Herrera (<alvherre[a]dcc.uchile.cl>) "The eagle never lost so much time as when he submitted to learn from the crow." (William Blake, citado por Nobody)
On Sun, Nov 17, 2002 at 19:06:40 +0000, * Tong * <tong@none.hub.org> wrote: > Hi, > > Hope this simple question has a simple solution: > How can I authorise root the same previliage as postgres? > > My postgres is password protected, I want to use 'psql -U postgres' as a > root without specifying password every time, or for a certain group of > users. How can I do that? I've been banning my head on the walls in > finding a way to achieve it. Still can't find a way to do it with > indent, md5 or even passwords authentication. Please help. If you are using postgres through a socket (and hence must be on the same machine as the server), running at least postgresql 7.2 and your OS supports getpeerid, then you can use ident authentication and permit root to connect as the postgres user without using a password. If you are running an identd server on the machine you are logged into, then you can use ident authentication over a network connection. My preferred way to access postgres is either to su from root to postgres to do things or to access as user postgres from my normal account.
Thank you for the reply. Bruno Wolff III wrote: >>How can I authorise root the same previliage as postgres? >> >>My postgres is password protected, I want to use 'psql -U postgres' as a >>root without specifying password every time, or for a certain group of > > If you are using postgres through a socket (and hence must be on the > same machine as the server), running at least postgresql 7.2 and your > OS supports getpeerid, then you can use ident authentication and > permit root to connect as the postgres user without using a password. All the anwsers should be yes, except that I don't know about getpeerid. I'm using RH8, BTW. Here is what I've been trying (postgresql 7.2 that comes along with RH8): In $PGDATA/pg_hba.conf, add: # TYPE DATABASE IP_ADDRESS MASK AUTH_T AUTH_ARG local template1 ident printf 'admins\troot\tpostgres\n' >> $PGDATA/pg_ident.conf killall -HUP postmaster It will still ask for password when 'psql template1' as root. Besides, specifying either root password or postgres password won't work. What is supposed to be the right way? PS. the following works. So I guess it is not the problem of ident: # TYPE DATABASE IP_ADDRESS MASK AUTH_T AUTH_ARG local sameuser ident sameuser
On Tue, Nov 19, 2002 at 01:29:48 +0000, * Tong * <tong@none.hub.org> wrote: > > All the anwsers should be yes, except that I don't know about getpeerid. > I'm using RH8, BTW. This will work on 2.2 and 2.4 linux kernels (and maybe earlier ones), so you should be alright. > > Here is what I've been trying (postgresql 7.2 that comes along with RH8): I have attached same pg_hba.conf and pg_ident.conf files that will illustrate what is possible. I am currently running 7.3, but I think it should work the same on 7.2.