Skip to main content

SSH authentication

authentik: 2026.2.4+

You can use the authentik Agent to authenticate SSH connections between endpoint devices using authentik credentials.

Linux, macOS, and Windows devices can initiate SSH connections. Currently, only Linux devices can serve as SSH endpoints. See Configure SSH authentication on an endpoint device section for more details.

When connected to an endpoint device in this way, sudo authorization can be handled by the authentik agent.

Prerequisites​

  • The authentik Agent must be deployed on both the source and SSH target devices.
  • The target device needs to be configured, see the Configure SSH authentication on an endpoint device section below.
  • The SSH client on the source device must be OpenSSH 8.9 or later. Check the version with ssh -V. Older clients don't send the target host's key to the SSH agent, so the authentik Agent can't request a certificate from authentik.
  • A profile must exist on the source device. Add one in the authentik Agent app or with ak config setup.
  • On Windows source devices, Windows Hello must be set up. The authentik Agent uses it for authorization prompts.

How to SSH to an endpoint device​

To SSH to a configured Linux host using the authentik Agent:

  1. Configure your SSH config to use the authentik Agent's SSH Identity Agent:

Edit ~/.ssh/config and add the following:

Host *
IdentityAgent "~/Library/Application Support/authentik/agent-ssh.sock"

The SSH Agent page of the authentik Agent app shows these settings for your device and whether your SSH client uses the authentik Agent.

  1. Open a Terminal session and run the following command:
ssh <hostname>
  1. When the authentik Agent prompts you, approve the login. The Agent remembers your answer for a limited time. Refer to Authorization prompts.
  2. After authentication, the SSH session connects.

Use a specific profile for a host​

The SSH agent socket in the previous section uses the active profile, which changes when you run ak switch-profile. authentik Agent 0.72 and later also provides a socket for each profile, which always uses that profile regardless of the active profile.

PlatformIdentityAgent value for the profile <profile>
Linux~/.local/share/authentik/agent-ssh-<profile>.sock
macOS~/Library/Application Support/authentik/agent-ssh-<profile>.sock
Windows//./pipe/authentik/socket-ssh-<profile>

A profile only has its own socket if its name consists of letters, digits, -, and _.

For example, to use the work profile for some hosts and the active profile for all other hosts on macOS:

Host *.work.company
IdentityAgent "~/Library/Application Support/authentik/agent-ssh-work.sock"

Host *
IdentityAgent "~/Library/Application Support/authentik/agent-ssh.sock"

SSH uses the first IdentityAgent value that matches a host, so add specific hosts before Host *.

Use other SSH keys with a fallback agent​

When IdentityAgent points to the authentik Agent, your SSH client no longer uses your other SSH agent, such as the system SSH agent, 1Password, or a hardware key agent. Connections to hosts that aren't managed by authentik, such as Git hosting services, then fail.

To continue using your other keys, configure a fallback agent. The ssh_fallback_agent setting requires authentik Agent 0.63 or later, and the Fallback agent form in the app requires 0.70 or later. The authentik Agent then handles connections as follows:

  1. If the host is a passthrough host, the Agent sends the request directly to the fallback agent, without a prompt.
  2. Otherwise, the Agent prompts you to approve the login and requests a certificate from authentik.
  3. If the Agent doesn't get a certificate, for example because authentik doesn't manage the host or you denied the prompt, the Agent sends the request to the fallback agent.

By default, github.com and gitlab.com are passthrough hosts. To avoid prompts for other hosts that aren't managed by authentik, add them as passthrough hosts.

To configure a fallback agent:

  1. Open the authentik Agent app and open the SSH Agent page.
  2. Under Fallback agent, configure the following settings:
    • Fallback agent socket: the absolute path of the other SSH agent's socket. The field suggests the SSH agent that was in use when the app started.
    • Extra passthrough hosts (optional): one known_hosts line per host, for example the output of ssh-keyscan git.company.
  3. Click Save.

Passthrough hosts are matched by their host key. If the host key of a passthrough host changes, update its line.

To stop using a fallback agent, clear Fallback agent socket and click Save.

Alternatively, configure the fallback agent with the ssh_fallback_agent setting. Refer to Agent settings and policies. If your administrator enforces this setting, the form is read-only.

Agent forwarding​

With ForwardAgent yes, the SSH agent of the authentik Agent is available on the host that you connect to. This allows you to:

  • Connect from that host to other hosts that are managed by authentik.
  • Run ak commands on that host without creating a profile there, if the authentik Agent isn't running on that host. The requests are sent to the authentik Agent on your device, which prompts you for approval.

Only forward the agent to hosts that you trust. Anyone with administrative access to a host can use a forwarded agent for as long as you're connected.

To prevent ak on remote hosts from reaching the authentik Agent on a device, set ssh.agent_tunnel to false. Refer to Agent settings and policies.

Configure SSH authentication on an endpoint device​

Authentication is only possible if the Linux device is aware of the authentik user which is attempting to authenticate. This can be achieved in one of two ways:

  1. Provision user accounts - Create users on the Linux device with usernames that match authentik users that need to authenticate to the device. This can be done manually or via automation tools like Ansible.
  2. libnss-authentik - This is a package that can be installed on the Linux device. It is an NSS module that makes the Linux device aware of authentik users. Similar to adding a Linux device to an Active Directory or LDAP domain.