9 Eylül 2019 Pazartesi

pg_hba.conf Dosyası - Hangi Bilgisayarların Bağlanabileceğini Belirtir

Giriş
Not:  postgresql.conf dosyası da bazı ayarları içerir. Bu dosyada hangi ethernet kartının (network card) dinleceği belirtilir.

Aslında bu dosya "Host Based Authentication" anlamına gelir. Ancak esasında hangi bilgisayarların bağlanabileceğini belirtir. Açıklaması şöyle
This file handles client authentication configuration and controls as per doc "which hosts are allowed to connect, how clients are authenticated, which PostgreSQL user names they can use, which databases they can access". You need to edit this file to enable remote connections. The content is self-explanatory in this file.
Sütun Başlıkları
1. Type
2. Database
3. User
4. Address
5. Method
Her satır 7 tane formattan bir tanesine sahip olabilir. Bu formatlar şöyle
local      database  user  auth-method  [auth-options]
host       database  user  address  auth-method  [auth-options]
hostssl    database  user  address  auth-method  [auth-options]
hostnossl  database  user  address  auth-method  [auth-options]
host       database  user  IP-address  IP-mask  auth-method  [auth-options]
hostssl    database  user  IP-address  IP-mask  auth-method  [auth-options]
hostnossl  database  user  IP-address  IP-mask  auth-method  [auth-options]
local Unix Doman Socket içindir
host IPv4 ve Ipv6 içindir
Örnek
Şöyle yaparız
#Type		DATABASE	USER	ADDRESS	        METHOD
#local is for Unix domain socket connections only
local		all		all			 trust

#IPv4 local connections
host		all		all	127.0.0.1/32     trust

#IPv6 local connections
host		all		all	::1/128	         trust

#Allow replication connections from localhost, by a user with 
#the replication privilege
local		replication	all			 trust
host 		replication	all	127.0.0.1/32     trust
host 		replication	all	::1/128	         trust

auth-method Alanı
Şu değerlerden birini alabilir. Eğer trust ise kullanıcı şifresiz login olur.
trust
reject
md5
password
gss
sspi
krb5
ident
peer
ldap
radius
cert
pam
Örnek
IPv4 ile her yerden bağlantıya izin vermek için bu dosyanın en altına bir satır ekleriz. Şöyle yaparız
host    all             all             0.0.0.0/0            md5
Örnek
IPv4 ve IPv6 ile her yerden bağlantıya izin vermek için bu dosyanın en altına bir satır ekleriz. Şöyle yaparız
host all all 0.0.0.0/0 md5
host all all ::/0 md5
replication Alanı
Şöyle yaparız
host replication pglogrepl 127.0.0.1/32 md5



Hiç yorum yok:

Yorum Gönder