Access networking home directory securely and SSH protocol transition feature #189
Labels
No labels
in progress
meeting
need info
ongoing work project
on hold
pending activity
release test
user documentation
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
server/tickets#189
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
When your home directory is placed on a networking file system, you want to obtain Kerberos ticket to authenticate against your NFS or SMB server in order to mount your home directory. In a normal setup, a login over SSH protocol does not delegate user's Kerberos ticket at all: it is insecure to delegate the initial ticket granting ticket (TGT) and even disabled in Active Directory for cross-domain trust setup. If you'd use password-based SSH login, SSSD or Winbind on the target SSH server will generate the Kerberos TGT. However, for all other methods (public key authentication, smartcard authentication, Kerberos without delegation, ...) such ticket would not be created.
Kerberos deployments such as Active Directory and FreeIPA allow applications to operate on behalf of users (Kerberos principals). Originally this came as an Active Directory extension documented in MS-SFU specification. MS-SFU ("services for users", S4U) defines two modes of operation:
Thus, there are two important stepping stones to solve the original networking home directory mounting problem:
First issue is being solved through introduction of S4U operations to OpenSSH. It is currently in development and can be tested through the following COPR repository:
COPR repo for Fedora 43-45:
dnf copr enable dbelyavs/openssh-gss-s4uTwo demos are provided:
https://youtu.be/hlxFCs_RIRE
https://youtu.be/Bx7_ZJskofo
Second issue is partially solved for both Active Directory and FreeIPA. In Active Directory resource-based constrained delegation allows NFS/SMB server service owner to grant permissions based on the SIDs present in the login token of of the requestor service (machine). It means machine accounts can be allowed to delegate user Kerberos tickets to NFS servers. In FreeIPA this problem is solved partially: there is a way to add such permissions but every single machine principal (
host/machine.name.tld) needs to be explicitly mentioned. A support for 'all machines' or a 'subset of machines' needs to be added to FreeIPA.S4U2Self operation gives a Kerberos ticket that can also be consumed directly by other applications which have access to the host keytab. For example,
pam_sss_gss.soPAM module (configured viaauthselect enable-feature with-gssapiin SSSD profile) accepts S4U2Self ticket for authentication. This is demonstrated in Demo 1 above.For local KDC the same infrastructure will be reused. Local KDC does not yet provide RBCD implementation, thus it needs to be added. At least for S4U2Self operation Local KDC should already work and can be made default for Fedora 45.
I'm attaching FreeIPA-specific demo document explaining how I created those videos.
I've landed these patches in rawhide, NVR is openssh-10.2p1-7.fc45
I have built a test version of Local KDC in COPR
abbra/krb5-test.Quick setup
To test you need Fedora Rawhide (there is a build for Fedora 44 as well):
Optionally install Samba:
In order to setup local KDC, run
localkdc-setupcommand:You'll get a deployment where local KDC is activated on demand whenever a Kerberos client such as
kinitconnects to the UNIX domain socket/run/localkdc/kdc.sock. All configuration is predefined, including Kerberos services for this host. The configuration is a bit opinionated: it sets up use of SSSD withlocalkdcdomain that usesproxyID provider pointing to/etc/passwd + /etc/groupand authentication provider using Kerberos (krb5). It also configures PAM stack to allowpam_sss_gssmodule and permits use of Kerberos tickets forsudoandsudo -iauthentication.User authentication
None of the Kerberos principals for user accounts are there. This is intentional.
If you create user accounts with
useradd <username> && passwd <username>then the local KDC will be able to see the accounts through systemd's userdb interface and will be able to authenticate them using their passwords via PAM servicesystem-auth.This flow is organized through the use of Kerberos OTP pre-authentication mechanism. As a result, you will see an OTP prompt when performing
kinit <username>. A speciallocalkdc-pam-authhelper will be triggered by the local KDC and will perform this authentication. After successful PAM authentication, local KDC will issue a Kerberos ticket with authentication indicator 'password' in it. We will add passwordless authentications later, mimicking FreeIPA deployments.Use of OTP preauthentication mechanism requires certain preconditions to be true for both Kerberos client and Kerberos KDC. We fulfill them by providing a Kerberos PKINIT configuration with a self-signed local CA, maintained by the
certmonger. Whenlocalkdc-setuptool is executed, it requests the certificates and configures Kerberos system to use this self-signed CA for automatically providing Anonymous PKINIT feature withauto_fast_armor = true.The combination of on-demand activating local KDC and on-demand authenticating PAM helper makes local KDC introduction transparent for migration of the existing deployments. Local KDC will not need creating additional Kerberos principals for existing users. Instead, it will fall back to ask their existing system passwords as Kerberos principal credentials.
Use of Kerberos tickets
Kerberos tickets obtained from the local KDC can be used for any of the local services that support GSSAPI.
localkdc-setupalready configures Kerberos services for common use cases:host/...as the main service for this host. It is used by SSSD, by OpenSSH server and bypam_sss_gssPAM modulecifs/...as the Samba serviceHTTP/...as the main HTTP service, which can be used by the Cockpit setup for local access from the browser running on the same system.See man
pam_sss_gssfor more details on how PAM authentication with GSSAPI is configured and performed. With the default configurationsudowill be able to accept these tickets for the users allowed to usesudoorsudo -iservices. Please note that due to howsudois implemented, you will be prompted to enter a password bysudo. Just hit enter, thenpam_sss_gsswill be able to recognize the existing Kerberos ticket and authenticate the account.Protocol transition and local KDC
OpenSSH server in Fedora supports protocol transition feature on systems where Kerberos is configured. It also works with local KDC for S4U2Self operation. The following SSH server configuration fragment allows to issue a Kerberos ticket for the user authenticated with any OpenSSH authentication method that doesn't result itself in Kerberos ticket:
The Kerberos ticket obtained through protocol transition can then be used for the operations which require a service ticket to
host/...service:sshclient towards the same host as this user. You may use public SSH keys here, e.g.sudoor any other PAM service withpam_sss_gssAuthentication towards other Kerberos services will require to perform S4U2Proxy operation which is currently not supported in local KDC.