[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Postgre Userzugriffe



("xpost" nach pgsql-de-allgemein@postgresql.org und
pgusers@postgres.de, da der OP die Frage dort ebenfalls gestellt hat)

Henning Follmann schrob:

> On Sun, Apr 17, 2005 at 03:02:53PM +0200, Frank Habermann wrote:
>> host all all 127.0.0.1 255.255.255.255 trust
>> 
>> wenn ich mir nun die doku schnappe interpretiere ich die zeile so:
>> alle user können von localhost zugreifen ohne das sie ein passwort
>> brauchen(zugriff über tcp)

> Die pg_hba.conf legt die zugriffsrechte fest mit der das Client Programm
> auf den Prozess zugreifen kann.
> Wenn Du willst, dass der db Nutzer sich authentifizieren muss musst Du
> natuerlich die Zugriffsrechte in der DB anpassen.
> Dass geschieht mit dem Befehl "alter user"
> Die Verwendung des Befehls kannst Du Dir mit \h alter user anzeigen
> lassen.
> Als Beispiel:
> ALTER USER frank WITH PASSWORD 'frankspassword';
>
> Jetzt muesste sich der user frank mit dem password frankspassword
> anmelden.

AFAIK wird, wenn in der pg_hba.conf "trust" steht, garkeine
Authentifizierung verlangt; unabhängig davon, ob ein Passwort für den
User gesetzt ist:

--8<---------------cut here---------------start------------->8---
$ initdb data/
$ echo host all all 127.0.0.1/32 trust > data/pg_hba.conf
$ pg_ctl -D data/ -o -p6666 start
$ psql -h 127.0.0.1 -p 6666 template1
Welcome to psql 8.1devel, the PostgreSQL interactive terminal.

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

template1=# alter user andreas with password 'foo';
ALTER USER
template1=# \q
$ psql -h 127.0.0.1 -p 6666 template1
Welcome to psql 8.1devel, the PostgreSQL interactive terminal.

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

template1=# \q
--8<---------------cut here---------------end--------------->8---

Erst nachdem in der pg_hba.conf explizit Passwort-Authentifizierung
verlangt ist, wird es auch abgefragt:

--8<---------------cut here---------------start------------->8---
$ echo host all all 127.0.0.1/32 password > data/pg_hba.conf 
$ pg_ctl -D data/ -o -p6666 restart
$ psql -h 127.0.0.1 -p 6666 template1
Password: 
Welcome to psql 8.1devel, the PostgreSQL interactive terminal.
[...]
--8<---------------cut here---------------end--------------->8---

HTH
Andreas



Reply to: