■サーバ
●バージョン
psql (PostgreSQL) 11.19
●ロール一覧イチラン
postgres=# \du
                                              ロール一覧
 ロール名 |                                    属性                                    | 所属グループ 
----------+----------------------------------------------------------------------------+--------------
 postgres | スーパーユーザ, ロール作成可, DB作成可, レプリケーション可, RLS のバイパス | {}
postgres=# 
※postgresロールは、パスワードを「password」に設定セッテイ
●ipv6設定セッテイ
ipv6はsysctlで無効化ムコウカ
●ident(authd)の
[root@centos7-1 ~]# ss -antup | grep 113
[root@centos7-1 ~]# 
■pg_hba.conf
-bash-4.2$ egrep -v "#|^$" 11/data/pg_hba.conf
@ local   all             all                                     peer
A host    all             all             127.0.0.1/32            ident
B host    all             all             ::1/128                 ident
C local   replication     all                                     peer
D host    replication     all             127.0.0.1/32            ident
E host    replication     all             ::1/128                 ident
F host    all     all             192.168.10.0/24                 md5
-bash-4.2$ 
接続セツゾクテスト
●TCP/IP経由ケイユ(localhost)
●OSユーザ(postgres)
-bash-4.2$ id
uid=26(postgres) gid=26(postgres) groups=26(postgres)
-bash-4.2$ psql -h localhost -U postgres -d postgres
psql: FATAL:  Ident authentication failed for user "postgres"
-bash-4.2$ 
⇒pg_hba.confのパターンAにマッチしてident認証ニンショウ不可フカ突破トッパできず。  
●OSユーザ(root)
[root@centos7-1 ~]# id
uid=0(root) gid=0(root) groups=0(root)
[root@centos7-1 ~]# psql -h localhost -U postgres -d postgres
psql: FATAL:  Ident authentication failed for user "postgres"
[root@centos7-1 ~]# 
⇒pg_hba.confのパターンAにマッチしてident認証ニンショウ不可フカ突破トッパできず。  
●Unixドメインソケット経由ケイユ(localhost)
●OSユーザ(postgres)
-bash-4.2$ id
uid=26(postgres) gid=26(postgres) groups=26(postgres)
-bash-4.2$ psql -U postgres -d postgres
psql (11.19)
help でヘルプを表示します。
postgres=# \q
-bash-4.2$ 
⇒pg_hba.confのパターン@にマッチしてpeer認証ニンショウ突破トッパ      
●OSユーザ(root)
[root@centos7-1 ~]# id
uid=0(root) gid=0(root) groups=0(root)
[root@centos7-1 ~]# psql -U postgres -d postgres
psql: FATAL:  Peer authentication failed for user "postgres"
[root@centos7-1 ~]# 
⇒pg_hba.confのパターン@にマッチしてpeer認証ニンショウ突破トッパできず。    
■pg_hba.conf
-bash-4.2$ egrep -v "#|^$" 11/data/pg_hba.conf
@ local   all             all                                     md5 ★md5に変更ヘンコウした
A host    all             all             127.0.0.1/32            md5 ★md5に変更ヘンコウした
B host    all             all             ::1/128                 ident
C local   replication     all                                     peer
D host    replication     all             127.0.0.1/32            ident
E host    replication     all             ::1/128                 ident
F host    all     all             192.168.10.0/24                 md5
-bash-4.2$ 
接続セツゾクテスト($HOME/.pgpassなし)
●TCP/IP経由ケイユ(localhost)
●OSユーザ(postgres)
-bash-4.2$ id
uid=26(postgres) gid=26(postgres) groups=26(postgres)
-bash-4.2$ psql -h localhost -U postgres -d postgres
ユーザ postgres のパスワード: 
psql (11.19)
help でヘルプを表示します。
postgres=# \q
-bash-4.2$ 
⇒pg_hba.confのパターンAにマッチしてパスワード認証ニンショウ(md5)。パスワード入力ニュウリョクして突破トッパ
●OSユーザ(root)
[root@centos7-1 ~]# id
uid=0(root) gid=0(root) groups=0(root)
[root@centos7-1 ~]# psql -h localhost -U postgres -d postgres
ユーザ postgres のパスワード: 
psql (11.19)
help でヘルプを表示します。
postgres=# \q
[root@centos7-1 ~]# 
⇒pg_hba.confのパターンAにマッチしてパスワード認証ニンショウ(md5)。パスワード入力ニュウリョクして突破トッパ
●Unixドメインソケット経由ケイユ(localhost)
●OSユーザ(postgres)
-bash-4.2$ id
uid=26(postgres) gid=26(postgres) groups=26(postgres)
-bash-4.2$ psql -U postgres -d postgres
ユーザ postgres のパスワード: 
psql (11.19)
help でヘルプを表示します。
postgres=# \q
-bash-4.2$ 
⇒pg_hba.confのパターン@にマッチしてパスワード認証ニンショウ(md5)。パスワード入力ニュウリョクして突破トッパ
●OSユーザ(root)
[root@centos7-1 ~]# id
uid=0(root) gid=0(root) groups=0(root)
[root@centos7-1 ~]# psql -U postgres -d postgres
ユーザ postgres のパスワード: 
psql (11.19)
help でヘルプを表示します。
postgres=# \q
[root@centos7-1 ~]# 
⇒pg_hba.confのパターン@にマッチしてパスワード認証ニンショウ(md5)。パスワード入力ニュウリョクして突破トッパ
接続セツゾクテスト($HOME/.pgpassあり)
●TCP/IP経由ケイユ(localhost)
●OSユーザ(postgres) .pgpassは「localhost:5432:*:postgres:password」
-bash-4.2$ id [root@centos7-1 ~]# lsof | grep 5432
uid=26(postgres) gid=26(postgres) groups=26(postgres) postmaste 29682       postgres    6u     unix 0xffff8ee976b41980       0t0     311925 /var/run/postgresql/.s.PGSQL.5432
-bash-4.2$ psql -h localhost -U postgres -d postgres postmaste 29682       postgres    7u     unix 0xffff8ee976b43740       0t0     311927 /tmp/.s.PGSQL.5432
psql (11.19) [root@centos7-1 ~]# 
help でヘルプを表示します。
[root@centos7-1 ~]# ss -antup | grep 5432 | grep ESTAB
postgres=# \q tcp    ESTAB      0      0      127.0.0.1:5432               127.0.0.1:45994               users:(("postmaster",pid=29954,fd=12))
-bash-4.2$  tcp    ESTAB      0      0      127.0.0.1:45994              127.0.0.1:5432                users:(("psql",pid=29953,fd=3))
⇒pg_hba.confのパターンAにマッチしてパスワード認証ニンショウ(md5)。パスワード入力ニュウリョクなしで突破トッパ [root@centos7-1 ~]# 
 lsof では2つからえていなく、ssではpsqlのコネクションが確認カクニンできるので、TCP/IP経由ケイユ
●OSユーザ(root) .pgpassは「localhost:5432:*:postgres:password」
[root@centos7-1 ~]# id [root@centos7-1 ~]# lsof | grep 5432
uid=0(root) gid=0(root) groups=0(root) postmaste 29682       postgres    6u     unix 0xffff8ee976b41980       0t0     311925 /var/run/postgresql/.s.PGSQL.5432
[root@centos7-1 ~]# psql -h localhost -U postgres -d postgres postmaste 29682       postgres    7u     unix 0xffff8ee976b43740       0t0     311927 /tmp/.s.PGSQL.5432
psql (11.19) [root@centos7-1 ~]# 
help でヘルプを表示します。
[root@centos7-1 ~]# ss -antup | grep 5432 | grep ESTAB
postgres=# \q tcp    ESTAB      0      0      127.0.0.1:5432               127.0.0.1:45998               users:(("postmaster",pid=30005,fd=12))
[root@centos7-1 ~]#  tcp    ESTAB      0      0      127.0.0.1:45998              127.0.0.1:5432                users:(("psql",pid=30004,fd=3))
⇒pg_hba.confのパターンAにマッチしてパスワード認証ニンショウ(md5)。パスワード入力ニュウリョクなしで突破トッパ [root@centos7-1 ~]# 
 lsof では2つからえていなく、ssではpsqlのコネクションが確認カクニンできるので、TCP/IP経由ケイユ
●Unixドメインソケット経由ケイユ(localhost)
●OSユーザ(postgres) .pgpassは「localhost:5432:*:postgres:password」
-bash-4.2$ id [root@centos7-1 ~]# lsof | grep 5432
uid=26(postgres) gid=26(postgres) groups=26(postgres) postmaste 29682       postgres    6u     unix 0xffff8ee976b41980       0t0     311925 /var/run/postgresql/.s.PGSQL.5432
-bash-4.2$ psql -U postgres -d postgres postmaste 29682       postgres    7u     unix 0xffff8ee976b43740       0t0     311927 /tmp/.s.PGSQL.5432
psql (11.19) postmaste 30053       postgres   12u     unix 0xffff8ee9365b7740       0t0     315824 /var/run/postgresql/.s.PGSQL.5432
help でヘルプを表示します。 [root@centos7-1 ~]# 
postgres=# \q [root@centos7-1 ~]# ss -antup | grep 5432 | grep ESTAB
-bash-4.2$  [root@centos7-1 ~]# 
⇒pg_hba.confのパターン@にマッチしてパスワード認証ニンショウ(md5)。パスワード入力ニュウリョクなしで突破トッパ
 lsof では2つからえて3つ、ssではコネクションが確立カクリツされていないので、Unixドメインソケッ経由ケイユ
●OSユーザ(root) .pgpassは「localhost:5432:*:postgres:password」
[root@centos7-1 ~]# id [root@centos7-1 ~]# lsof | grep 5432
uid=0(root) gid=0(root) groups=0(root) postmaste 29682       postgres    6u     unix 0xffff8ee976b41980       0t0     311925 /var/run/postgresql/.s.PGSQL.5432
[root@centos7-1 ~]# psql -U postgres -d postgres postmaste 29682       postgres    7u     unix 0xffff8ee976b43740       0t0     311927 /tmp/.s.PGSQL.5432
psql (11.19) postmaste 30111       postgres   12u     unix 0xffff8ee9365b5dc0       0t0     316918 /var/run/postgresql/.s.PGSQL.5432
help でヘルプを表示します。 [root@centos7-1 ~]# 
postgres=# \q [root@centos7-1 ~]# ss -antup | grep 5432 | grep ESTAB
[root@centos7-1 ~]#  [root@centos7-1 ~]# 
⇒pg_hba.confのパターン@にマッチしてパスワード認証ニンショウ(md5)。パスワード入力ニュウリョクなしで突破トッパ
 lsof では2つからえて3つ、ssではコネクションが確立カクリツされていないので、Unixドメインソケッ経由ケイユ