Host Aliases

A Sudo Manager host alias provides a way to group several hosts that share a common set of sudoers policies. This is not the same as a Sudoers Host_Alias, which is resolved inside a sudoers policy. Rather, a Sudo Manager host alias is used by the Sudo Manager Policy Server to select an appropriate policy by mapping different hostnames to the same arbitrary string.

Host aliases are manipulated using the pbdbutil command on the sudo Policy Server:

  • To map host names to an alias:
    pbdbutil --sudo -A <ALIAS> <hostnames…>
  • To unmap host names from an alias:
    pbdbutil --sudo -X <ALIAS> <hostname…>
  • To list current aliases:
    pbdbutil --sudo -G [pattern]

Sudo policies are stored in a database table that is keyed on path name and version. The version increments whenever a new copy is uploaded. The path name is composed of two parts:

<fqdn>@/<sudoers_path>
  1. The client's fully qualified domain name
  2. The client's default sudoers path (usually /etc/sudoers) as reported by sudo -V
If your sudo Policy Server defines sudoersdir in /etc/pb.settings as /etc/pbsudoers, and your Linux client's name is client0.bt.net, then the pathname to identify its policy is:
client0.bt.net@/etc/sudoers

By default, each new client's policy is uploaded to the sudo Policy Server to a unique path during installation after client registration.

The default sudoers path can vary by host. While it is commonly /etc/sudoers, third-party versions and custom builds may use different paths, like /usr/local/etc/sudoers. Use sudo -V to discover the current path. Each alias should be used only for hosts with the same sudoers path. Hosts with the same sudoers policy but a different sudoers path should use a different alias.

The client governs the right part following the hostname or alias. The pbsudomgr.so plugin defaults to /etc/sudoers on all platforms. Use the sudoers_file plugin argument to specify a different path.

A Privilege Management for Unix and Linux Sudo Manager host alias can map several hosts to the same policy by substituting an arbitrary ALIAS for the hostname:

<ALIAS>@/<sudoers_path>

pbsudoinstall can easily create host aliases during installation on sudo hosts. For more information, please see the Privilege Management for Unix and Linux Sudo Manager Installation Guide.

To implement an alias with policies outside of pbsudoinstall, first create a policy for the alias, then assign hosts to the alias. Do all of this on the sudo Policy Server. This can be done before or after the clients are installed, and reinstallation of the clients is not required.

  1. Determine the sudoersdir path defined in the sudo Policy Server's settings:
    # pbcall -getstringsetting sudoersdir

    We use /etc/pbsudoers in the following steps.

  2. Invent an alias name in all uppercase letters. For simplicity, we use ALIAS.
  3. Determine the default sudoers file path. For familiarity, we use /etc/sudoers.
  4. Create the policy directory and sudoers file.
    # mkdir -p /etc/pbsudoers/ALIAS/etc
    # vi /etc/pbsudoers/ALIAS/etc/sudoers
  5. Verify the policy syntax with visudo, if available.
    # visudo -c -f /etc/pbsudoers/ALIAS/etc/sudoers
  6. Import the policy into the PBDB.
    # pbdbutil --sudo -i /etc/pbsudoers/ALIAS/etc/sudoers
    # pbdbutil --sudo -l
  7. Map clients to the alias.
    # pbdbutil --sudo -A ALIAS <host1> <host2> …
    # pbdbutil --sudo -G ALIAS
  8. Adjust the sudoers_file plugin argument in sudo.conf on all clients, especially those platforms with third-party or custom sudo. For example:
    # grep Plugin /etc/sudo.conf
    Plugin sudoers_policy /usr/lib/beyondtrust/pb/pbsudoers.so sudoers_ file=/etc/sudoers
    Plugin sudoers_io /usr/lib/beyondtrust/pb/pbsudoers.so
  9. Verify the configuration on each client:
    # sudo -V; sudo -l