Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nyCzY-0004dB-Oc for pgsql-general@arkaria.postgresql.org; Mon, 06 Jun 2022 13:42:00 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nyCzX-0000pG-Af for pgsql-general@arkaria.postgresql.org; Mon, 06 Jun 2022 13:41:59 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nyCzW-0000p2-Ul for pgsql-general@lists.postgresql.org; Mon, 06 Jun 2022 13:41:59 +0000 Received: from mail-ot1-x32a.google.com ([2607:f8b0:4864:20::32a]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1nyCzU-0007EB-FD for pgsql-general@lists.postgresql.org; Mon, 06 Jun 2022 13:41:57 +0000 Received: by mail-ot1-x32a.google.com with SMTP id g13-20020a9d6b0d000000b0060b13026e0dso10776343otp.8 for ; Mon, 06 Jun 2022 06:41:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=1wBzT5adu5Im0UtKvLDD8K2DThzR8ZDGCvNKSohyHzA=; b=dW/s6YwwnlAicLOLemuFZcchnp/JxyGqjwYzxm9+kflU60HeO3hvk/j0h5jhsQUUTp 9vCOQUAtiFQmeUQ3TbtP2WtzRv5e3bAMXJ1lCobzuYXZxRo4GZdbczDWOqUi9UQvNqRA suRi3xOHb+ECWDJKSYKRwWyrglaWWRyL4y8hyRs5hbGCtqHc8gs4WAUlvQuyd5/5DY8U bDegi/rkpvq0CFBBt1LWLOjcMgkdIFuHMeixYz2QPcPUYU+KySYrt97cnGfbhQFGm7lP ilaFGNmFcFimVYvopUS7miVSUpeT1PRJqcuDm2c5fPiSB7xJinsmEM4c64INFMYcD0Np EMvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=1wBzT5adu5Im0UtKvLDD8K2DThzR8ZDGCvNKSohyHzA=; b=at7LAYCPdS/nDSE7iQ0yB8l8hVhLyO5cr6GRoWt13J6ZaHTs8XCH8dUFOonEMwi19M 9x2rpq0hfPVurEbxtYzshmj+sXE/M1se6wGHFX2K1BSz3YinYOU1tGPjh9dJChg41U6w Frtl8mDH2hoxtdOTQ0sj/o0weBKzVl7aq+EC47KmMpXOftDDR4zBsWX+bjy3Tu1D089v QqnvC+MslSExf1FXPt5ZC/C8oC7sSy7d4IBPEfJKyB8ovGNJk3HmpQ5Zyher16/XMjtt pEvQT2cVSM1Vq8BbC3fr8c9k0SE5zqYEoyuGP5jBy23O+RMPK4fRBAmVNF4cCYohYCsO 0jJA== X-Gm-Message-State: AOAM5313abSZpNzNsGwyeaiKN5fw1BGm7u8XXlfWCwdCguX0OUNQhiZC 2UmlBn9hiXqifHZ2hhcpkbVUe90boqW03Yc9KOdqgwV7FqU= X-Google-Smtp-Source: ABdhPJwpLFDgLOCHH53q+3i64kNvkINTmP4xKSEzVRUVROr5OSglkJcjqOriF8PYRJQlnw5QSbsx8r9payfjMU/Ewhs= X-Received: by 2002:a05:6830:22d6:b0:60b:1af5:2751 with SMTP id q22-20020a05683022d600b0060b1af52751mr10107385otc.39.1654522914285; Mon, 06 Jun 2022 06:41:54 -0700 (PDT) MIME-Version: 1.0 References: <9f1254f4ffc24460a3c0ba34f062f33e@dst.dk> <02f8b9de128f49078c4eb2af1e5438c2@dst.dk> In-Reply-To: <02f8b9de128f49078c4eb2af1e5438c2@dst.dk> From: Michael van der Kolff Date: Mon, 6 Jun 2022 23:41:44 +1000 Message-ID: Subject: Re: GSSAPI authentication To: Niels Jespersen Cc: pgsql-general list Content-Type: multipart/alternative; boundary="000000000000942d3a05e0c7a2e7" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000942d3a05e0c7a2e7 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable The part that you're missing, I think, is that Kerberized services require a service account. The SPN (service principal name) is the name that is used in Kerberos contexts for that service account. PostgreSQL uses postgres/${hostname}@${realm} by default - see https://www.postgresql.org/docs/14/gssapi-auth.html. The important part to note here is that $hostname must match what is registered in the SPN for the user that you're using as the service account in AD. It might (I don't know) have to match what AD believes about the host from its PTR records for that domain as well. --Michael On Mon, Jun 6, 2022 at 11:33 PM Niels Jespersen wrote: > *Fra:* Michael van der Kolff > *Sendt:* 6. juni 2022 14:26 > *Til:* Niels Jespersen > *Cc:* pgsql-general list > *Emne:* Re: GSSAPI authentication > > > > >This sounds like your PG service was unable to authenticate itself to AD= . > > > > > >There's probably a trick to that somewhere - AD doesn't really want to b= e > a Kerberos server, it just happens to use it =F0=9F=98=89 > > > > But it works fine when the same AD-user connects from Windows to the same > postgres (Linux) server. Auth fails when the user initiates login from a > Linux box (that otherwise uses Kerberized ressources just fine). > > > > Niels > --000000000000942d3a05e0c7a2e7 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
The part that you're missing, I think, is that Kerberi= zed services require a service account.

The SPN (service principal n= ame) is the name that is used in Kerberos contexts for that service account= . PostgreSQL uses postgres/${hostname}@${realm} by default - see=C2=A0https://www.post= gresql.org/docs/14/gssapi-auth.html.

The important p= art to note here is that $hostname must match what is registered in the SPN= for the user that you're using as the service account in AD. It might = (I don't know) have to match what AD believes about the host from its P= TR records for that domain as well.

--Michael

On Mon, Jun 6, 2022 at 11:33 PM Niels Jespersen <NJN@dst.dk> wrote:

Fra: Michael van der Kolff <mvanderkolff@gmail.com>
Sendt: 6. juni 2022 14:26
Til: Niels Jespersen <NJN@dst.dk>
Cc: pgsql-general list <pgsql-general@lists.postgresql.org> Emne: Re: GSSAPI authentication

=C2=A0

>This sounds like your PG se= rvice was unable to authenticate itself to AD.

>=C2=A0=

>There's probably a tric= k to that somewhere - AD doesn't really want to be a Kerberos server, i= t just happens to use it = =F0=9F=98=89

=C2=A0

But it works fine when the same AD-user connects fro= m Windows to the same postgres (Linux) server. Auth fails when the user ini= tiates login from a Linux box (that otherwise uses Kerberized ressources just fine).

=C2=A0

Niels

--000000000000942d3a05e0c7a2e7--