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 1gzlR2-0006RZ-Q9 for pgsql-general@arkaria.postgresql.org; Fri, 01 Mar 2019 16:54:56 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gzlR1-0008OW-4M for pgsql-general@arkaria.postgresql.org; Fri, 01 Mar 2019 16:54:55 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gzlR0-0008OP-Ob for pgsql-general@lists.postgresql.org; Fri, 01 Mar 2019 16:54:54 +0000 Received: from tamriel.snowman.net ([96.255.250.162]) by makus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gzlQw-0006Ll-KE for pgsql-general@lists.postgresql.org; Fri, 01 Mar 2019 16:54:53 +0000 Received: by tamriel.snowman.net (Postfix, from userid 1000) id B32855F7A0; Fri, 1 Mar 2019 11:54:49 -0500 (EST) Date: Fri, 1 Mar 2019 11:54:49 -0500 From: Stephen Frost To: Jean-Philippe Chenel Cc: "pgsql-general@lists.postgresql.org" Subject: Re: PostgreSQL (linux) configuration with GSSAPI to a Windows domain Message-ID: <20190301165449.GG6197@tamriel.snowman.net> References: <4182C0C4-7555-415A-992D-3141AAA9176D@LIVE.CA> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="XWgyk5vHxG2WH408" Content-Disposition: inline In-Reply-To: <4182C0C4-7555-415A-992D-3141AAA9176D@LIVE.CA> User-Agent: Mutt/1.5.24 (2015-08-30) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --XWgyk5vHxG2WH408 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Greetings, * Jean-Philippe Chenel (jp.chenel@LIVE.CA) wrote: > I'm trying to configure authentication between PostgreSQL database server= on linux and Windows Active Directory. >=20 > First part of configuration is working but when I'm trying to authenticat= e from Windows client, it is not working with message: Can't obtain databas= e list from the server. SSPI continuation error. The specified target is un= known or unreachable (80090303) > On Windows: >=20 > Domain is AD.CORP.COM >=20 > Host is: WIN.AD.CORP.COM, IP is 192.168.1.173 >=20 > On Linux (Ubuntu 16.04) >=20 > hostname is UBUNTU.ad.corp.com, IP is 192.168.1.143 >=20 > DNS are configured to reach the AD sytem (.173) >=20 > PostgreSQL 9.6.9 on x86_64-pc-linux-gnu (Ubuntu 9.6.9-2.pgdg16.04+1), com= piled by gcc (Ubuntu 5.4.0-6ubuntu1~16.04.9) 5.4.0 20160609, 64-bit That's a rather out of date version of PG. :( You should update to 9.6.12. > I've created =E0 service user called POSTGRES and a normal user in AD cal= led ubuntupg. Did you make sure in AD to check the "User has AES256"? > Finally I've created the SPN: >=20 > setspn -A POSTGRES/UBUNTU.ad.corp.com POSTGRES I've not had to do this in the past.. > Generated the keytab to put on the linux server: >=20 > ktpass -out postgres.keytab -princ POSTGRES/UBUNTU.ad.corp.com@AD.CORP.CO= M -mapUser POSTGRES -pass 'thepassword' -crypto all -ptype KRB5_NT_PRINCIPAL This looks mostly correct. > On the linux /etc/krb5.conf: >=20 > [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 >=20 > [realms] > AD.CORP.COM =3D { >=20 > kdc =3D WIN.AD.CORP.COM > } >=20 > [domain_realm] > ad.corp.com =3D AD.CORP.COM >=20 > .ad.corp.com =3D AD.CORP.COM That seems ok. > Making this command work and klist return a ticket: >=20 > kinit -V -k -t /etc/postgresql/9.6/main/postgres.keytab POSTGRES/UBUNTU.a= d.corp.com@AD.CORP.COM >=20 > klist -k /etc/postgresql/9.6/main/postgres.keytab >=20 > POSTGRES/UBUNTU.ad.corp.com@AD.CORP.COM You should make sure to use klist to show the KVNO and the encryption types too (usually -e or -v works, depending on what version of Kerberos you're using). What does the klist on the client look like, with verbose/enctype info shown? > Here is the added onfiguration to postgresql.conf >=20 > krb_server_keyfile =3D '/etc/postgresql/9.6/main/postgres.keytab' You might try enabling case-insensitive princs in PG using krb_caseins_users too. > Here is the configuration of pg_hba.conf >=20 > host all all 0.0.0.0/0 gss >=20 > Up to here, all is working as expected, kinit with ubuntupg is also worki= ng well. ubuntupg and ubuntupg@ad.corp.com is also created on the database.= The probleme is when I try, from a Windows client, connecting to the DB. So you're able to get in using Kerberos on the Ubuntu system? > psql.exe -h 192.168.1.143 -U ubuntupg >=20 > Can't obtain database list from the server. SSPI continuation error. The = specified target is unknown or unreachable (80090303) >=20 > PostgreSQL log file show: >=20 > 2019-02-28 14:02:54.178 EST [6747] [unknown]@[unknown] LOG: 00000: conne= ction received: host=3D192.168.1.176 port=3D57254 > 2019-02-28 14:02:54.178 EST [6747] [unknown]@[unknown] LOCATION: Backend= Initialize, postmaster.c:4188 > 2019-02-28 14:02:54.331 EST [6747] ubuntupg@ubuntupg FATAL: 28000: GSSAP= I authentication failed for user "ubuntupg" > 2019-02-28 14:02:54.331 EST [6747] ubuntupg@ubuntupg DETAIL: Connection = matched pg_hba.conf line 92: "host all all 0.0.0= =2E0/0 gss" > 2019-02-28 14:02:54.331 EST [6747] ubuntupg@ubuntupg LOCATION: auth_fail= ed, auth.c:307 >=20 > psql.exe -h 192.168.1.143 -U ubuntupg@ad.corp.com >=20 > 2019-02-28 14:06:35.992 EST [6866] [unknown]@[unknown] LOG: 00000: conne= ction received: host=3D192.168.1.176 port=3D57282 >=20 > 2019-02-28 14:06:35.992 EST [6866] [unknown]@[unknown] LOCATION: Backend= Initialize, postmaster.c:4188 >=20 > 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.corp.= com" >=20 > 2019-02-28 14:06:36.148 EST [6866] ubuntupg@ad.corp.com@ubuntupg@ad.corp.= com DETAIL: Connection matched pg_hba.conf line 96: "host all = all 0.0.0.0/0 gss" >=20 > 2019-02-28 14:06:36.148 EST [6866] ubuntupg@ad.corp.com@ubuntupg@ad.corp.= com LOCATION: auth_failed, auth.c:307 Have you checked to make sure that the time on the server and the time on the client and the time on the AD server are all more-or-less in sync (within 5 minutes)? There is also the krbsrvname option which might be useful. Thanks! Stephen --XWgyk5vHxG2WH408 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBCgAGBQJceWPZAAoJEO1sijiDR2RVq6cP/ihaJ6hX4icAmucTgPWTmqL6 21N0dAPcT6CU3WmvTYfXXtMxMth0/DznzIwXfUQTYYsb562iTxBFRcxXzgkyAEpz cU7KpJLsuuW6BUje1lHpa4gkwEVX1/WZL8zc4yiip67t509LL46ksgC377YjAFC5 Y4wrYmYorKqOlCI6tIvldIcTuN+TFr1qTnPeUgosmaaLqC/JUtWoncrOIHWeRgRK RHm4cGWDov12gdQAoodHB2uWtr3rvF3XMmnRR2ktnc5ONSZZZNzkgJfrfHZIe/+c i0vCi+W76S+PYyhlImeJbw3qEjv4eNpztOnqQLw1+yMR/n1kVswUNPVS+e99SYDq bpQiZ2UWNmB3F25seL4lNh3eTVXOcsc3ePNj/ZjsVuZcdzWWAiS+OtL6uhXpSH3D gtTeo9uz367ss4nKgNQLJjZ3jSRvcR0tmkL29C1RDaiNOxQHiHhaq35q2Ob9jSZZ gup5HtcCFjjVHTa2cTQV9+iWZQV6xGmwyQbn2A8DVgQpqPMG0/z2imPOZdS5Zbc2 M3AaO9E+3G6xiOeFakFv7VaB67dY2ZxQ5r6ix8Nho1AJYchHBiVYUhKoQoJ/SKlS 8b3TNNC6JwgwE9PyxVcF9W2SX4KfBUUf8YrkYt2ucKameP08QLJ8x70oxiLBjJbL 8Fz9NqcqBB2CZ0eiuKfm =MxMn -----END PGP SIGNATURE----- --XWgyk5vHxG2WH408--