From owner-freebsd-fs@freebsd.org Fri Oct 12 00:37:58 2018 Return-Path: Delivered-To: freebsd-fs@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 3900C10CD16E for ; Fri, 12 Oct 2018 00:37:58 +0000 (UTC) (envelope-from rmacklem@uoguelph.ca) Received: from CAN01-TO1-obe.outbound.protection.outlook.com (mail-eopbgr670052.outbound.protection.outlook.com [40.107.67.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (Client CN "mail.protection.outlook.com", Issuer "GlobalSign Organization Validation CA - SHA256 - G3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id CA9628A2CA for ; Fri, 12 Oct 2018 00:37:57 +0000 (UTC) (envelope-from rmacklem@uoguelph.ca) Received: from YTOPR0101MB1820.CANPRD01.PROD.OUTLOOK.COM (52.132.44.160) by YTOPR0101MB1497.CANPRD01.PROD.OUTLOOK.COM (52.132.48.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1228.25; Fri, 12 Oct 2018 00:37:56 +0000 Received: from YTOPR0101MB1820.CANPRD01.PROD.OUTLOOK.COM ([fe80::65af:417a:161f:f4eb]) by YTOPR0101MB1820.CANPRD01.PROD.OUTLOOK.COM ([fe80::65af:417a:161f:f4eb%3]) with mapi id 15.20.1228.020; Fri, 12 Oct 2018 00:37:56 +0000 From: Rick Macklem To: Peter Eriksson , Felix Winterhalter CC: "freebsd-fs@freebsd.org" Subject: Re: NFSv4 Kerberos mount from Linux Thread-Topic: NFSv4 Kerberos mount from Linux Thread-Index: AQHUW9DS+OLl3kMYEUaTZ7pIOOpJR6UPKibngAl2Y4CAAGctboAAu6iAgAEEoaU= Date: Fri, 12 Oct 2018 00:37:55 +0000 Message-ID: References: <30f6446c-6fed-4b1e-9cae-9c417974ec46@audiofair.de> , <33A0F0BC-4AD8-4DE3-B484-42B7FB208B6A@ifm.liu.se> In-Reply-To: <33A0F0BC-4AD8-4DE3-B484-42B7FB208B6A@ifm.liu.se> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=rmacklem@uoguelph.ca; x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; YTOPR0101MB1497; 6:JfN/EjNqgWTcBMpPwS0G/VCF+KDXD2306Lxh0SZYZ4LhKtBsgrBeKuacIOPOUsB+fbcgfpp5TFW2clkYLdIVBgoiwars6ELxLKdH2VpieR8UMcN4YUlNk41kgnQ1Iw5B5i/cwG0Ahn9Sqdglb5UqsEcj4DXrq1rbv95IRIRV5T1ugvqpOnPJfSrl/kWLiFqkuot8lMD8BhYKVx1t5Tp2MR33YbwQ0gv7ZKPDXrZPhkujS/6LIZFMR9TAVFRIh1ThsAscM4hNqq641XFDVp91nUmPE7OcxKF1T4BHhkLyyx02vtDlxJK0VFbQN5gmbQ8cR8tmMjXhGyk4f3H98vKaRdmZT0RgTOmp6KjygWQK9T2z+vMiEHkSj+TEcAToMIuNpm43qwgy1vR8T6oSmeBVkuMyy18AcDKFBsq1xXcJppaiBXCq5SGq95xW4qRf6TZBN+4pC/A+8WyuOigIkGeq7w==; 5:qwYNFj0fUuSWv1BtRkY2mkQqyyiazQ+riiw1Da8Yt2SCxIst1sbYJhdvc8wCA8cPvHbh3Gy41TanJBRxL8fZM/t6oXPQ51nTJ3+hKzsMLkzhKGIPkESsGEvPc8rpmja68QJDa5vW9wn0ONTCykmV/gWbZroWRCUHTiz9G9njx/8=; 7:Wxg8ckPu9TOuH9FkBKUju7mu1lQAlvwfIDvF1QxKqLPzWNmmUmnAUKgIvVjTkDFPjq1+TST+I5kcsm6h2cxNHru5WId7XgeswTRFobGvHnb/JCJhk15juioYi2FMUQF8dGevPgZzOyZMWXqLtdXriDVf4heE4onq05a6tupw6rOHTx4eprTwXz/3dkV0oz0JHSkJ5TdtpCD3YR2/tRC6cT2O3yaD1jLJH14bvEu8nBx7uElvgImn0bltkBXzPaOl x-ms-exchange-antispam-srfa-diagnostics: SOS; x-ms-office365-filtering-correlation-id: 438287dc-9696-4aec-4dc2-08d62fdaf3db x-microsoft-antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(2017052603328)(7153060)(7193020); SRVR:YTOPR0101MB1497; x-ms-traffictypediagnostic: YTOPR0101MB1497: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(158342451672863)(788757137089)(12572780692934)(269456686620040)(192374486261705)(75325880899374)(18154293887054); x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(6040522)(2401047)(5005006)(8121501046)(93006095)(93001095)(10201501046)(3002001)(3231355)(944501410)(4982022)(52105095)(149066)(150057)(6041310)(20161123558120)(20161123564045)(20161123562045)(20161123560045)(201703131423095)(201702281529075)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699051); SRVR:YTOPR0101MB1497; BCL:0; PCL:0; RULEID:; SRVR:YTOPR0101MB1497; x-forefront-prvs: 0823A5777B x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(396003)(376002)(39860400002)(346002)(136003)(366004)(51444003)(189003)(199004)(486006)(99286004)(106356001)(105586002)(46003)(11346002)(446003)(256004)(476003)(71200400001)(305945005)(71190400001)(81156014)(8676002)(81166006)(14444005)(102836004)(8936002)(33656002)(74482002)(76176011)(7696005)(186003)(110136005)(9686003)(53936002)(53546011)(55016002)(6306002)(6506007)(6436002)(2900100001)(93886005)(229853002)(74316002)(5660300001)(6246003)(97736004)(5250100002)(68736007)(14454004)(4744004)(966005)(45080400002)(25786009)(786003)(2906002)(316002)(478600001)(86362001)(4326008); DIR:OUT; SFP:1101; SCL:1; SRVR:YTOPR0101MB1497; H:YTOPR0101MB1820.CANPRD01.PROD.OUTLOOK.COM; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: uoguelph.ca does not designate permitted sender hosts) x-microsoft-antispam-message-info: Iy+Y+NaaCePCeiQVglD5CN+6OTqejORVXD3m9xFCUtvBMjAY94Qtaq1yXDZVy5ne/VXjyw2/S5CdrDOhlyruC39zReUwf42VHBGqsiPkZA3w0oW7KEat7Bb43/JvQd7qlrJO/NH2rHl5X6/IU+XtjjYBpOKVGm9/aYPrwZgZQAmRvLhqs8mgLmFrBkX4AshG1dmW44dVtnsg5MQ/51ZBmquE2qDf03p1G7eCTtvohWrLHMR+WGRaU6e2jrkCiIBYLBT7LiMgyu3qidH4v/ihXgVMq1K6OLdI+i7PZRhrgO65qSZx/hJ9Btdlko8OCGvI5no0sSiZDlzkKfaB8lSGl5affkGqw0SjRIkJaQbIl0U= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: uoguelph.ca X-MS-Exchange-CrossTenant-Network-Message-Id: 438287dc-9696-4aec-4dc2-08d62fdaf3db X-MS-Exchange-CrossTenant-originalarrivaltime: 12 Oct 2018 00:37:55.8954 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: be62a12b-2cad-49a1-a5fa-85f4f3156a7d X-MS-Exchange-Transport-CrossTenantHeadersStamped: YTOPR0101MB1497 X-BeenThere: freebsd-fs@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: Filesystems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 12 Oct 2018 00:37:58 -0000 From: Peter Eriksson wrote: >Just a few comments (random brain-dump) in case someone else is having pro= blems >with NFS & Kerberos. > > >We=92ve been using NFSv4 with Kerberos from Linux clients here for many ye= ars (with >Solaris-based NFS servers and MIT Kerberos) and lately using Fre= eBSD as the NFS >server OS (in an Microsoft AD Kerberos environment). I agree with the other post that this is a very useful document and it woul= d be nice to keep it somewhere where it is easier to find than in the mailing li= st archive. I don't know where that could be, so hopefully someone else in FreeBSD-land can suggest a good place? The one area you don't discuss (and maybe isn't really a problem?) is what ticket encryption type(s) you use. Kerberized NFS still uses DES (someday this may change, but I think that re= quires implementation of RPCSEC_GSS V3), so it needs an 8byte session key. (I have never seen a documented way to convert a session key of greater tha= n 8bytes into an 8byte session key for RPCSEC_GSS to use. As such, I have no= idea what happens if you choose a ticket encryption type that results in a grea= ter than 8byte key.) Here's a couple of minor comments: [lots of good stuff snipped] >4. rc.conf (we have a lot of users in our AD so we have to use a large num= ber for >usermax, replace =93liu.se=94 with your NFSv4 =93do= main=94 for >nfsuserd_flags) > >gssd_enable=3D"YES" >nfs_server_enable=3D"YES" >nfsv4_server_enable=3D"YES" >nfscbd_enable=3D"YES" Since the nfscbd is only used by the client (and only when delegations or p= NFS is enabled in the server), I believe this is harmless, but unnecessary for th= e server. >mountd_enable=3D"YES" >nfsuserd_enable=3D"YES" >nfsuserd_flags=3D"-manage-gids -domain liu.se -usertimeout = 10 -usermax 100000 16" > Btw, if you have many clients doing NFSv4.0 mounts, tuning of your DRC is a= dvised. (The defaults are for extremely small NFS servers.) NFSv4.1 mounts don't us= e the DRC, so if that is what your clients are doing, this isn't necessary. It's a little off topic, but for NFSv4.0 (and/or NFSv3) mounts and a reason= able sized NFS server, reasonable settings in /etc/sysctl.conf might be: vfs.nfsd.tcpcachetimeo=3D600 vfs.nfsd.tcphighwater=3D100000 vfs.nfsd.v4statelimit=3D10000000 vfs.nfsd.clienthashsize=3D10000 vfs.nfsd.statehashsize=3D10000 - If most/all of your mounts are NFSv4.1, then instead of the above, you mi= ght want: vfs.nfsd.sessionhashsize=3D10000 >5. Make sure you use NTPD so the clock is correct. > > >* All clients (Solaris 10, OmniOS, MacOS 10.12-10.14, FreeBSD 11.0-11.2, C= entOS 7, >Debian 9, Ubuntu 17-18 tested): > >1. Make sure FQDN is in /etc/hosts > >2. Make sure you use NTPD so the clock is correct. > >3. Have a =93host/FQDN@REALM=94 Kerberos host principal in /etc/krb5.keyta= b (nfs or >root is not needed for NFS-mounting to work) I'm guessing that you use the "gssname=3Dhost" mount option for your FreeBS= D clients? (The name after "gssname=3D" is whatever name you have before "/FQDN@REALM" for this principal name.) This is what I referred to as the host-based initiator credential. Thanks for posting this, rick 4. We use a fairly default /etc/krb5.conf, sort of like: [libdefaults] default_realm =3D REALM dns_lookup_realm =3D true ticket_lifetime =3D 24h renew_lifetime =3D 7d forwardable =3D true default_ccache_name =3D KEYRING:persistent:%{uid} KEYRING probably only works on Linux and there are some problems with KEYRI= NG in Debian & Ubuntu since not everything in it supports it due to them us= ing Heimdal instead of MIT (like for smbclient) but it mostly works. Works = fine in CentOS 7 though - in general CentOS 7 feels more =93enterprise=94-r= eady than Debian & Ubuntu. The old classic FILE-ccaches should work fine th= ough. For mounting we use the automounter and a "executable map=94 (perl script) = that looks up records in DNS (Hesiod-style) since the built-in Hesiod suppo= rt in most automounters is a bit.. lacking. Works quite well. You can find = the scripts we use here: http://www.grebo.net/~peter/nfs (The dns-update scripts use data from an SQL database so probably isn=92t d= irectly usable to anybody else. We use the same SQL database to populate a = locally developed BerkeleyDB-based NSS-database on each FreeBSD server in o= rder to speed things up since AD/LDAP-looks with ~90k users and silly amoun= ts of AD groups takes forever, even with cacheing). Some Linux-specific stuff: Packages needed: CentOS: - nfs-utils - libnfsidmap - nfs4-acl-tools - autofs Debian: - keyutils - nfs-kernel-server # rpc.idmapd needs this due to a bug in Debian Ubuntu: - keyutils Other nice-to have packages: - hesiod - autofs-hesiod Some settings to check for: /etc/default/nfs-common: NEED_IDMAPD=3Dyes NEED_GSSD=3Dyes /etc/idmapd.conf (replace =93liu.se=94 with your NFSv4 =93= domain=94): Domain=3Dliu.se /etc/request-key.d/id_resolver.conf (should be there already if using a m= odern Linux and you=92ve added the packages above): create id_resolver * * /usr/sbin/nfsidmap %k %d MacOS: Basically require the latest - 10.14 (Mojave) - for things to work smoothly= . In theory 10.12 & 10.13 should work but there is some bug in them that ca= uses the OS to panic when you try to use NFS & Kerberos. 10.11 and earlier = doesn=92t support good enough encryption for us=85 But with 10.14 you just= need to get a Kerberos ticket and then you can mount things just fine. /etc/nfs.conf should contain (replace =93liu.se=94 with your= NFSv4 =93domain=94): nfs.client.default_nfs4domain=3Dliu.se (There are a lot of problems you can run into with Microsofts AD implementa= tion of Kerberos too that we=92ve had to be fighting with, but that=92s a w= hole other topic) - Peter On 10 Oct 2018, at 23:47, Rick Macklem > wrote: Felix Winterhalter wrote: On 10/4/18 5:21 PM, Rick Macklem wrote: [stuff snipped] I am now trying to mount this directory as root first without having to deal with user keytabs or tickets. This works fine with -sec=3Dsys and nfsv4.1 and nfsv3 and -sec=3Dkrb5p. This does not however work with nfsv4 and krb5p or any other krb5 flavor. Sorry, I'm not sure what you are saying here. Is it 1 - no version of NFS works for krb5p or 2 - NFSv4.1 works for krb5p, but NFSv4.0 does not or 3 - only nfsv3 works for krb5p [snipped lots of text] #3 is indeed what was happening. I could mount with krb5p for nfsv3 (which I was not aware was even doable) however nfsv4 would stubbornly refuse to do any mounting. Yes, RPCSEC_GSS was done by Sun for NFSv3 and it was a good fit, since NFSv= 3 does not have any server state to maintain. As such, all RPCs are atomic op= erations done by users (which for Kerberized mounts must have a TGT in a credential = cache). NFSv4 wasn't really a good fit for the model, because the NFSv4 server main= tains lock state (NFSv4 Opens are a form of lock used by Windows at file open tim= e). There are "state maintenance" operations that must be done by the user doin= g the mount (usually root), where they typically don't have a TGT in a creden= tial cache. --> The ugly solution for this is typically a host-based client credential = in a keytab on the client. (Usually a principal like "root/client-host.domain@REAL= M" or "host/client-host.domain@REALM" or "nfs/client-host.domain@REALM" in the default keytab on the client.) I have now after a lot of try and error figured out what I need to do in order to make it work. To start with I have kerberos credentials with both host/ and nfs/ on both client and server. Mounting nfsv4 shares with krb5p from a linux server has also worked in this context. Yes, I'm assuming that satisfied the host-based client credential as I desc= ribed above. I leave you to judge whether what I found out is intended behaviour or if something weird is going on. Yes, sounds like intended behaviour, since the client must have a Kerberos credential to use for the "state maintenance" operations that are not done = on behalf of a user. My exports file originally looked something like this: /nfsTests/ /nfsTests/testexport /nfsTests/otherexport -maproot=3Droot -sec=3Dkrb5p clients V4: /nfsTests -sec=3Dkrb5p clients Which allowed me to do nfsv3 krb5p mounts but not nfsv4 krb5p mounts. Changing the exports file to this: /nfsTests/ /nfsTests/testexport /nfsTests/otherexport -maproot=3Droot -sec=3Dkrb5p clients V4: /nfsTests -sec=3Dkrb5p,krb5i clients This suggests that there is a bug in the client, where it uses krb5i instea= d of krb5p at some point in the mounting process. (I have also seen cases where the cl= ient erroneously falls back on using sys at some point in the mounting process.) (You did mention before you were using the Linux client. If you are using a= FreeBSD client, I would be interested in looking at this.) Allows nfsv4 krb5p mounts to work for some reason I do not understand. Not setting the -sec option on the V4 line apparently defaults to -sec=3Dsys and doesn't allow any krb5 mounts. I'm not sure that this is a good default as I wasn't even aware that the -sec option needed to be set on this line. In FreeBSD, defaults are meant to maintain backwards compatibility. This me= ans that AUTH_SYS should work by default. Also, AUTH_SYS is what 99.9999% of FreeBSD NFS mounts still use, from what I've seen.) I've got packet traces of the nfsv3 krb5 and krb5i mounts and I'll make traces of the two nfsv4 mount attempts and send them to you if you're interested. I'm still not sure what exactly is happening here. The successful one for NFSv4 might be interesting. If you look at it in wireshark, I suspect you'd find somewhere during the mount that it did RPCs which were not krb5p and that would show why the addition of krb5i made it work. I did suggest you start with -sec=3Dsys:krb5:krb5i:krb5p and, once that wor= ks, remove the security flavours one at a time until the mount doesn't work. (Then you capture packets for the minimal case that does work and look at what security flavours the client is using for all RPCs done during the mou= nt.) You now know why almost no one uses Kerberized NFSv4 mounts. Unfortunately, the NFSv4 working group has never gotten around to a better solution. Discussion of a host based encryption technique using something like SSL has happened, but no one has gone beyond that. rick _______________________________________________ freebsd-fs@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/freebsd-fs To unsubscribe, send any mail to "freebsd-fs-unsubscribe@freebsd.org"