Skip to content

LDAP server setup

1. A service account

Create a service account in AD for the CA, e.g. bastionxp-ca-svc. It only needs to read people and groups, which every account can by default. Give it a long random password that does not expire, and put the password into a file only the CA's user can read:

sudo install -m 600 -o bastionxp-ca /dev/null /etc/bastionxp-ca/ldap-password
sudo vi /etc/bastionxp-ca/ldap-password

2. LDAPS

Make sure the domain controllers speak LDAPS (port 636). They do once they have a certificate, usually from AD CS. Export the root that issued it (PEM) for ca_file, unless the CA machine trusts it already.

openssl s_client -connect dc1.corp.example.com:636 -showcerts </dev/null

3. Configure BastionXP CA

ldap:
  url: ldaps://dc1.corp.example.com
  ca_file: /etc/bastionxp-ca/corp-root.pem
  base_dn: DC=corp,DC=example,DC=com
  bind_dn: CN=bastionxp-ca-svc,OU=Service Accounts,DC=corp,DC=example,DC=com
  bind_password_file: /etc/bastionxp-ca/ldap-password
  # Only groups below this count. Recommended.
  group_base_dn: OU=Groups,DC=corp,DC=example,DC=com

access:
  - groups: [linux-users]
    ssh_principals: ["{short_username}"]
  - groups: [ca-admins]
    admin: true

4. Restart and check

sudo systemctl restart bastionxp-ca
sudo -u bastionxp-ca bxp doctor --config /etc/bastionxp-ca/bastionxp-ca.yaml

doctor checks that the directory is reachable and accepts the service account. The server started log line says ldap_login=true.

Settings

Key Default Meaning
url ldaps://host[:port], or ldap:// with start_tls: true. Plain ldap:// without StartTLS is refused: passwords would go over it.
start_tls false StartTLS on an ldap:// URL.
ca_file system roots The root of the directory's certificate. The certificate is always checked.
base_dn Where people are searched.
bind_dn The service account.
bind_password_file Its password.
group_base_dn base_dn Only groups below it count.
user_filter (&(objectClass=user)(sAMAccountName={username})) Finds the person by what they type, e.g. alice.
username_attribute userPrincipalName Their name in the rules and the logs: [email protected], as with OIDC at Entra ID. sAMAccountName gives alice.
group_filter (&(objectClass=group)(member:1.2.840.113556.1.4.1941:={user_dn})) Their groups, also through other groups (AD's matching rule for nested membership).
x509.cert_profile tls-client The profile of people's own TLS client certificates.
ssh.cert_profile ssh-user The profile of people's own SSH certificates.

The defaults fit Active Directory.

Groups in the rules

A group can be written by its name (linux-users) or by its full name (CN=linux-users,OU=Groups,DC=corp,DC=example,DC=com). The full name is safer: group names are not unique in AD, and anyone allowed to create a group somewhere could create another ca-admins. group_base_dn closes most of that: groups outside it do not count at all.

access:
  - groups: ["CN=ca-admins,OU=Groups,DC=corp,DC=example,DC=com"]
    admin: true

Several domain controllers

url takes one address. Use a DNS name that resolves to several DCs (the domain name itself usually does), as long as every DC's certificate is valid for it.