How can I configure cockpit to login through browser passkey
- User
How can I configure cockpit to login through browser passkey
Assistant
Cockpit does not natively support direct login via browser passkeys (WebAuthn/FIDO2) as a built-in authentication method. Cockpit primarily authenticates against the underlying Linux system's PAM (Pluggable Authentication Modules) stack, using system users and their passwords, or sometimes SSH keys if configured to do so for specific scenarios.
Browser passkeys, based on WebAuthn, are typically handled by a dedicated Identity Provider (IdP) or an authentication service acting as a reverse proxy.
If you want to achieve "login through browser passkey" to access Cockpit, you'll need to set up an authentication proxy / Single Sign-On (SSO) solution in front of Cockpit.
Here's the conceptual setup and the components involved:
The Recommended Approach: Reverse Proxy with an Identity Provider (IdP)
This is the most robust and secure way to achieve passkey login for Cockpit.
-
Your System Users: Cockpit still relies on standard Linux user accounts. The users who will log in via passkey must still exist on the Linux system where Cockpit is running. Their permissions (e.g., sudo access) will dictate what they can do within Cockpit.
-
A Reverse Proxy: This will sit in front of Cockpit.
- Examples: Nginx, Apache HTTPD, Caddy.
- Purpose: It intercepts all traffic destined for Cockpit. It will handle the initial authentication process (by redirecting to your IdP) and then forward authenticated requests to Cockpit.
-
An Identity Provider (IdP) or Authentication Service with WebAuthn/Passkey Support: This is the core component that manages user accounts and performs the passkey authentication.
- Self-hosted Examples:
- Keycloak: A powerful open-source IdP that supports WebAuthn/FIDO2 for multi-factor authentication (MFA) and passwordless login. You'd integrate it with your reverse proxy (e.g., using OpenID Connect or SAML).
- Authentik: Another excellent open-source IdP with built-in WebAuthn/Passkey support, often easier to set up for proxying applications.
- Authelia: An open-source authentication and authorization server that can be used as a companion for reverse proxies like Nginx, Caddy, or Traefik. It supports various MFA methods, including FIDO2.
- Pomerium: An identity-aware access proxy that can integrate with various IdPs and enforce policies.
- Cloud-based Examples (less common for a single Cockpit instance, but possible): Okta, Auth0, Azure AD, etc.
- Self-hosted Examples:
-
Cockpit Configuration for External Authentication:
- Once the reverse proxy has authenticated a user via the IdP, it needs to tell Cockpit who the user is.
- Cockpit supports authenticating users via HTTP headers, commonly
X-Remote-User. - You'll need to configure your reverse proxy to add this header (e.g.,
X-Remote-User: <authenticated-username>) to requests forwarded to Cockpit. - You might need to adjust PAM configuration on your Linux system to allow
cockpit-ws(Cockpit's web service) to trust this header for specific users. This typically involves using a PAM module likepam_succeed_iforpam_execin conjunction withpam_unix.
Conceptual Flow
- User tries to access Cockpit: User opens browser and navigates to
https://cockpit.yourdomain.com. - Reverse Proxy intercepts: The request hits your reverse proxy (Nginx, Caddy, etc.).
- Authentication Redirect: The reverse proxy, configured with your IdP, detects no active session and redirects the user's browser to the IdP's login page (e.g.,
https://idp.yourdomain.com/login). - IdP Authentication: On the IdP's page, the user authenticates using their configured method, which now includes a passkey.
- The IdP registers/uses the passkey with the browser's WebAuthn API.
- The user might simply tap their device, use Face ID/Touch ID, or unlock their OS for the passkey.
- IdP Redirects Back: Upon successful passkey authentication, the IdP redirects the user's browser back to the reverse proxy, including a token or cookie indicating success and the authenticated username.
- Reverse Proxy Authorizes & Forwards: The reverse proxy validates the token/cookie, ensures the user is authenticated, and adds the
X-Remote-Userheader with the authenticated username (e.g.,X-Remote-User: alice). It then forwards the request to the local Cockpit instance (e.g.,http://localhost:9090). - Cockpit Logs In: Cockpit receives the request, sees the
X-Remote-Userheader, and logs inalicewithout requiring a separate password, leveraging the PAM configuration to trust this external authentication. The useralicemust exist on the Linux system.
Key Considerations
- Complexity: This setup is significantly more complex than a direct Cockpit login. It involves multiple services (reverse proxy, IdP, Cockpit, Linux system users) and their integration.
- TLS/SSL: Ensure that both your reverse proxy and your IdP are configured with valid SSL certificates for secure communication (
https). - User Provisioning: Users authenticated by the IdP still need corresponding user accounts on the Linux machine running Cockpit for Cockpit to function correctly for them.
- Privileges: The authenticated users still need the appropriate
sudoor group memberships on the Linux system to perform administrative tasks within Cockpit. The SSO just handles who you are, not what you can do. - Maintenance: You'll be responsible for maintaining the reverse proxy and the IdP.
Why direct PAM FIDO2 is generally not "browser passkey" for web logins
While there are PAM modules like
pam_fido2that allow using FIDO2 keys (e.g., YubiKeys) for local logins (SSH, console), these are typically for physical security keys and a different type of authentication flow than a browser-synced passkey. They don't directly integrate with the web-based WebAuthn API the way an IdP does for a browser. A browser passkey is designed to be seamless within the browser context.In summary: To log into Cockpit using a browser passkey, you need to implement a full-fledged authentication proxy/SSO solution with an Identity Provider that supports WebAuthn/Passkeys, sitting in front of your Cockpit instance.
-
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.