Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gzUYi-00009H-UT for pgsql-general@arkaria.postgresql.org; Thu, 28 Feb 2019 22:53:45 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gzUYh-00029A-K9 for pgsql-general@arkaria.postgresql.org; Thu, 28 Feb 2019 22:53:43 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gzUYh-000293-7C for pgsql-general@lists.postgresql.org; Thu, 28 Feb 2019 22:53:43 +0000 Received: from mail-oln040092001079.outbound.protection.outlook.com ([40.92.1.79] helo=NAM01-BY2-obe.outbound.protection.outlook.com) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gzUYQ-0000zb-OT for pgsql-general@lists.postgresql.org; Thu, 28 Feb 2019 22:53:42 +0000 Received: from SN1NAM01FT023.eop-nam01.prod.protection.outlook.com (10.152.64.51) by SN1NAM01HT244.eop-nam01.prod.protection.outlook.com (10.152.64.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1643.11; Thu, 28 Feb 2019 22:53:22 +0000 Received: from BYAPR03MB4485.namprd03.prod.outlook.com (10.152.64.51) by SN1NAM01FT023.mail.protection.outlook.com (10.152.64.168) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1643.11 via Frontend Transport; Thu, 28 Feb 2019 22:53:22 +0000 Received: from BYAPR03MB4485.namprd03.prod.outlook.com ([fe80::7976:3c8d:5ff9:6ace]) by BYAPR03MB4485.namprd03.prod.outlook.com ([fe80::7976:3c8d:5ff9:6ace%4]) with mapi id 15.20.1643.019; Thu, 28 Feb 2019 22:53:22 +0000 From: Jean-Philippe Chenel To: "pgsql-general@lists.postgresql.org" Subject: PostgreSQL (linux) configuration with GSSAPI to a Windows domain Thread-Topic: PostgreSQL (linux) configuration with GSSAPI to a Windows domain Thread-Index: AQHUz7d9UULqD41FdUeTtwaihw7FOw== Date: Thu, 28 Feb 2019 22:53:22 +0000 Message-ID: <4182C0C4-7555-415A-992D-3141AAA9176D@LIVE.CA> Accept-Language: fr-CA, en-US Content-Language: fr-CA X-MS-Has-Attach: X-MS-TNEF-Correlator: x-incomingtopheadermarker: OriginalChecksum:A79F3CA4A5C05FE53037ED997A9E0E1E4F00EBEC95CFFB70709E0E8C71BBFCA0;UpperCasedChecksum:4D6939C3658BF610E2CB961A396D076DA7886AD6B694D41252EF889601EDE585;SizeAsReceived:6773;Count:42 x-ms-exchange-messagesentrepresentingtype: 1 x-tmn: [FHsyO86wIMvOQ0KKpb+8Asi4UShIRJNMzdrDgPmC8D1ryyJUY+roxilwCpa3Rb0k] x-ms-publictraffictype: Email x-incomingheadercount: 42 x-eopattributedmessage: 0 x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(201702061078)(5061506573)(5061507331)(1603103135)(2017031320274)(2017031323274)(2017031324274)(2017031322404)(1603101475)(1601125500)(1701031045);SRVR:SN1NAM01HT244; x-ms-traffictypediagnostic: SN1NAM01HT244: x-microsoft-antispam-message-info: Y6Uvhqvuy0lMDQ2+SNSQ9S5nB3dHEoxXsOVId0QG2vWXVONWJPTYTwFriAFH+eOD Content-Type: multipart/alternative; boundary="_000_4182C0C47555415A992D3141AAA9176DLIVECA_" MIME-Version: 1.0 X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-Network-Message-Id: 76195202-1ed0-4532-6731-08d69dcf8a60 X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-originalarrivaltime: 28 Feb 2019 22:53:22.4498 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1NAM01HT244 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --_000_4182C0C47555415A992D3141AAA9176DLIVECA_ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable I'm trying to configure authentication between PostgreSQL database server o= n linux and Windows Active Directory. First part of configuration is working but when I'm trying to authenticate = from Windows client, it is not working with message: Can't obtain database = list from the server. SSPI continuation error. The specified target is unkn= own or unreachable (80090303) On Windows: Domain is AD.CORP.COM Host is: WIN.AD.CORP.COM, IP is 192.168.1.173 On Linux (Ubuntu 16.04) hostname is UBUNTU.ad.corp.com, IP is 192.168.1.143 DNS are configured to reach the AD sytem (.173) PostgreSQL 9.6.9 on x86_64-pc-linux-gnu (Ubuntu 9.6.9-2.pgdg16.04+1), compi= led by gcc (Ubuntu 5.4.0-6ubuntu1~16.04.9) 5.4.0 20160609, 64-bit I've created =E0 service user called POSTGRES and a normal user in AD calle= d ubuntupg. Finally I've created the SPN: setspn -A POSTGRES/UBUNTU.ad.corp.com POSTGRES Generated the keytab to put on the linux server: ktpass -out postgres.keytab -princ POSTGRES/UBUNTU.ad.corp.com@AD.CORP.COM = -mapUser POSTGRES -pass 'thepassword' -crypto all -ptype KRB5_NT_PRINCIPAL On the linux /etc/krb5.conf: [libdefaults] debug=3Dtrue default_realm =3D AD.CORP.COM dns_lookup_realm =3D false dns_lookup_kdc =3D false ticket_lifetime =3D 24h renew_lifetime =3D 7d forwardable =3D true [realms] AD.CORP.COM =3D { kdc =3D WIN.AD.CORP.COM } [domain_realm] ad.corp.com =3D AD.CORP.COM .ad.corp.com =3D AD.CORP.COM Making this command work and klist return a ticket: kinit -V -k -t /etc/postgresql/9.6/main/postgres.keytab POSTGRES/UBUNTU.ad.= corp.com@AD.CORP.COM klist -k /etc/postgresql/9.6/main/postgres.keytab POSTGRES/UBUNTU.ad.corp.com@AD.CORP.COM Here is the added onfiguration to postgresql.conf krb_server_keyfile =3D '/etc/postgresql/9.6/main/postgres.keytab' Here is the configuration of pg_hba.conf host all all 0.0.0.0/0 gss Up to here, all is working as expected, kinit with ubuntupg is also working= well. ubuntupg and ubuntupg@ad.corp.com is also created on the database. T= he probleme is when I try, from a Windows client, connecting to the DB. psql.exe -h 192.168.1.143 -U ubuntupg Can't obtain database list from the server. SSPI continuation error. The sp= ecified target is unknown or unreachable (80090303) PostgreSQL log file show: 2019-02-28 14:02:54.178 EST [6747] [unknown]@[unknown] LOG: 00000: connect= ion received: host=3D192.168.1.176 port=3D57254 2019-02-28 14:02:54.178 EST [6747] [unknown]@[unknown] LOCATION: BackendIn= itialize, postmaster.c:4188 2019-02-28 14:02:54.331 EST [6747] ubuntupg@ubuntupg FATAL: 28000: GSSAPI = authentication failed for user "ubuntupg" 2019-02-28 14:02:54.331 EST [6747] ubuntupg@ubuntupg DETAIL: Connection ma= tched pg_hba.conf line 92: "host all all 0.0.0.0= /0 gss" 2019-02-28 14:02:54.331 EST [6747] ubuntupg@ubuntupg LOCATION: auth_failed= , auth.c:307 psql.exe -h 192.168.1.143 -U ubuntupg@ad.corp.com 2019-02-28 14:06:35.992 EST [6866] [unknown]@[unknown] LOG: 00000: connect= ion received: host=3D192.168.1.176 port=3D57282 2019-02-28 14:06:35.992 EST [6866] [unknown]@[unknown] LOCATION: BackendIn= itialize, postmaster.c:4188 2019-02-28 14:06:36.148 EST [6866] ubuntupg@ad.corp.com@ubuntupg@ad.corp.co= m FATAL: 28000: GSSAPI authentication failed for user "ubuntupg@ad.corp.co= m" 2019-02-28 14:06:36.148 EST [6866] ubuntupg@ad.corp.com@ubuntupg@ad.corp.co= m DETAIL: Connection matched pg_hba.conf line 96: "host all = all 0.0.0.0/0 gss" 2019-02-28 14:06:36.148 EST [6866] ubuntupg@ad.corp.com@ubuntupg@ad.corp.co= m LOCATION: auth_failed, auth.c:307 Thank you very much for your help. Best regards, --_000_4182C0C47555415A992D3141AAA9176DLIVECA_ Content-Type: text/html; charset="iso-8859-1" Content-ID: <15BB1DBC6A6CDD4CA6AD53BBC73D73DA@sct-15-20-1580-16-msonline-outlook-9c1c1.templateTenant> Content-Transfer-Encoding: quoted-printable

I'm trying to configur= e authentication between PostgreSQL database server on linux and Windows Ac= tive Directory.

Domain is AD.CORP.COM<= /span>

Host is: WIN.AD.CORP.C= OM, IP is 192.168.1.173

hostname is UBUNTU.ad.= corp.com, IP is 192.168.1.143

DNS are configured to = reach the AD sytem (.173)

PostgreSQL 9.6.9 on x8= 6_64-pc-linux-gnu (Ubuntu 9.6.9-2.pgdg16.04+1), compiled by gcc (Ubuntu= 5.4.0-6ubuntu1~16.04.9) 5.4.0 20160609, 64-bit

I've created =E0 servi= ce user called POSTGRES and a normal user in AD called ubuntupg. 

Finally I've created t= he SPN:

setspn -A POSTGRES/UBUNTU.ad.<=
span class=3D"pln" style=3D"margin:0px; padding:0px; border:0px; font-style=
:inherit; font-variant-caps:inherit; font-stretch:inherit; line-height:inhe=
rit; vertical-align:baseline; box-sizing:inherit">corp.com POSTGRES

Generated the keytab t= o put on the linux server:

ktpass -out postgres=
.keytab -princ POSTGRES/UBUNTU.ad.corp.com@AD.CORP<=
/span>.COM -mapUser POSTGRES -pass=
 'thepassword' -crypto all-ptype KRB5_NT_PRINCIPAL=

On the linux /etc/krb5= .conf:

[libdefaul=
ts]=

  debug
=3Dtrue
default_realm =3D AD<= /span>.CORP.COM
  dns_lookup_realm
=3D false
  dns_lookup_kdc
=3D false
  ticket_lifetime
=3D 2= 4h
  rene= w_lifetime
=3D 7d
  forwardable
=3D true

[r= ealms]
  AD
.CORP.CO= M =3D
{=0A=
    kdc
=3D WIN= .AD.CORP.<= /span>COM
  }

[domain_realm]
&n= bsp; ad
.corp
.com =3D AD.CORP.COM=0A=
 
.ad.corp.com= =3D AD.CORPCOM

Making this command wo= rk and klist return a ticket:

kinit -V -k -t /etc/postgresql/9.6/main/postgres.keytab POSTGRES=
/UBUNTU.ad.corp.com@AD.CORP.COM=0A=
=0A=
klist -k /etc/postgresql/9.6/main/postgres.keytab=0A=
=0A=
POSTGRES/<=
span class=3D"pln" style=3D"margin:0px; padding:0px; border:0px; font-style=
:inherit; font-variant-caps:inherit; font-stretch:inherit; line-height:inhe=
rit; vertical-align:baseline; box-sizing:inherit">UBUNTU.ad.corp<=
/span>.com@AD.CORP.COM

Here is the added onfi= guration to postgresql.conf

krb_server_keyfile =3D '/etc/postgresql/9.6/=
main/postgres.keytab'

Here is the configurat= ion of pg_hba.conf

host    al=
l              all            0.0.0.0/0 gss<=
/span>

Up to here, all is wor= king as expected, kinit with ubuntupg is also working well. ubuntupg and ub= untupg@ad.corp.com is also created on the database. The probleme is when I = try, from a Windows client, connecting to the DB.

psql.exe -h 192.168.1.143 -<=
span class=3D"pln" style=3D"margin:0px; padding:0px; border:0px; font-style=
:inherit; font-variant-caps:inherit; font-stretch:inherit; line-height:inhe=
rit; vertical-align:baseline; box-sizing:inherit">U ubuntupg<=
/code>

PostgreSQL log file sh= ow:

2019-02-28=
 14:02:54.=
178 EST [6747] [unknown]@[unknown] LO=
G:  00000:=
 connection received: host<=
span class=3D"pun" style=3D"margin:0px; padding:0px; border:0px; font-style=
:inherit; font-variant-caps:inherit; font-stretch:inherit; line-height:inhe=
rit; vertical-align:baseline; box-sizing:inherit">=3D192.168.1.176 port=3D57254
2019-02-28
14::54.178 EST [6747]
[unknown]@[unk= nown] LOCATION: BackendInitialize, postmaster.c:4188
2019-02-28= 14:02:54.= 331 EST [6747] ubuntupg@ubuntupg FATAL
: 28000: GSSAPI= authentication failed for = user "ubuntupg"
2019-02-28 14:02:54.331 EST = [6747] ubuntupg@ubuntupg DE= TAIL: Connection matched pg_hba.conf line 9= 2: "host all all 0.= 0.0.0/0 gss"=
2019-02-28
14:02:54.331 EST [6747 ubuntupg@ubuntupg LOCATION: auth_failed, auth.c:307

psql.exe -h 192.168.1.= 143 -U ubuntupg@ad.corp.com

2019-02-28=
 14:06:35.=
992 EST [6866] [unknown]@[unknown] LO=
G:  00000:=
 connection received: host<=
span class=3D"pun" style=3D"margin:0px; padding:0px; border:0px; font-style=
:inherit; font-variant-caps:inherit; font-stretch:inherit; line-height:inhe=
rit; vertical-align:baseline; box-sizing:inherit">=3D192.168.1.176 port=3D57282=0A=

2019-02-28
14:06:35.992 EST [6866 [unknown]@[unknown] LOCATION: BackendInitialize, postmaster.c:4188=0A=
2019-02-28 14:06:36.148 EST [6866 ubuntupg@ad.corp.com@ubuntupg@ad.corp.com FATAL: 28000: GSSAPI authentication failed for user "ubuntupg@ad.c= orp.com"=0A=
2019-02-28 14:06:36.148 EST [6866 ubuntupg@ad.corp.com@ubuntupg@ad.corp.com DETAIL: Conne= ction matched pg_hba.conf line 96: "host all = all 0.0.0.0/0 gss"=0A=
2019-02-28 14:06:36.148 EST [6866 ubuntupg@ad.corp.com@ubuntupg@ad.corp.com LOCATION: aut= h_failed,<= span class=3D"pln" style=3D"margin:0px; padding:0px; border:0px; font-style= :inherit; font-variant-caps:inherit; font-stretch:inherit; line-height:inhe= rit; vertical-align:baseline; box-sizing:inherit"> auth.c:307

Thank you very much fo= r your help.

Best regards,

--_000_4182C0C47555415A992D3141AAA9176DLIVECA_--