PAM and sudo issues

Troubleshooting guide for sudo with MFA and the Alpamon PAM module (alpamon-pam). Each section starts with the message you see, then explains the cause and the fix.

”A terminal is required to authenticate”

On sudo-rs hosts (Ubuntu 25.10 and later), a sudo command run without a terminal—for example through alpacon exec—can fail with:

sudo: A terminal is required to authenticate

This means the sudo attempt did not complete Alpacon authorization. Unlike classic sudo, sudo-rs cannot show the reason when no terminal is attached, so it prints this generic message instead. The most common causes are:

  • The command was denied—for example, no sudo policy on the work session matches it—and the reason is hidden because there is no terminal.
  • sudo with MFA is disabled for the workspace.
  • The sudo command did not originate from a tracked Alpacon session.

Find the real cause: run journalctl -u alpamon on the server around the time of the attempt and look for these lines.

Log lineMeaning
No session found for PIDThe sudo did not come from a tracked Alpacon session. Run it inside an approved work session or an interactive Websh session.
sudo_approval response timeoutAlpacon sent the request but received no answer from the server in time. Check connectivity and retry.
Processing sudo_approval response with approved=false and an error_codeThe command was explicitly denied. Look up the code in “Alpacon denied this sudo command”.

The user has no sudoers rule

Depending on the sudo implementation, a user with no permission to run sudo sees one of:

# sudo-rs (Ubuntu 25.10+)
sudo: I'm sorry user. I'm afraid I can't do that

# classic sudo
user is not in the sudoers file.

On Alpacon-managed hosts, the sudoers rule that grants sudo through Alpacon (%alpacon) is installed together with the PAM module (alpamon-pam). Seeing this message usually means alpamon-pam is not installed on the server. Check whether the package is present:

bash
# Debian/Ubuntu
dpkg-query -W alpamon-pam
 
# RHEL/CentOS/Rocky/Alma/Fedora, openSUSE/SLES
rpm -q alpamon-pam

To reinstall it:

  • A single server: from Alpacon, click Install or upgrade alpamon-pam on the server’s Agent card or run alpacon agent install-pam <server> with the CLI. Both send the install_pam action, which installs the package as root through the host’s package manager. While Sudo through Alpacon is off for the workspace, the button is disabled and the CLI request is refused, so turn the setting on first. On the host itself, install the package with the system package manager—apt-get install -y alpamon-pam on Debian/Ubuntu, yum install -y alpamon-pam on RHEL-based systems, zypper --non-interactive install alpamon-pam on openSUSE and SLES. See installation.
  • The package is present but /etc/sudoers.d/alpacon is gone: the action does nothing on a host already at the current version, so reinstall from the shell—apt-get install --reinstall -y alpamon-pam or yum reinstall -y alpamon-pam—to restore the file.
  • The whole workspace: if Sudo through Alpacon is turned off, turning it back on in Access rules reinstalls alpamon-pam on all currently connected servers.

sudo fails or asks for the root password on openSUSE or SLES

openSUSE and SLES need alpamon-pam 1.1.5 or later. Earlier versions fail in one of three ways:

VersionWhat you see
1.1.2 or earlierzypper install alpamon-pam stops with nothing provides 'jansson'.
1.1.3Every sudo on the server fails with unable to load /usr/lib/sudo/sudo/alpacon_approval.so.
1.1.4sudo asks Alpacon users for the root password, which they don’t have.

Upgrade from a root shell on the server with zypper --non-interactive install alpamon-pam. If sudo itself fails (1.1.3), open the root shell another way, such as su - with the root password or the server’s console. When the server’s detail page offers Install or upgrade alpamon-pam, it does the same upgrade through the agent and works even when sudo fails.

Servers registered with an earlier openSUSE/SLES install command may also have /etc/sudoers.d/alpacon-wheel. Alpacon users don’t need it, so you can delete it unless an account you manage yourself, such as the user an Ansible play connects as, relies on it.

”Alpacon denied this sudo command”

When a sudo refusal includes an error code, the terminal prints:

Alpacon denied this sudo command (SUDO_NO_WORKSESSION_POLICY).

The code tells you why it was denied and what to do. Each entry under “What to do” opens with the explanation Alpacon sends with the code, word for word. When a code can be refused at more than one gate, the entry has one explanation per gate, each after a label such as approval gate. The rest of the entry says where to make the change.

The workspace setting is Sudo through Alpacon in Access rules. For session scope, add Sudo on the session page or with alpacon work-session update --scope. For policies, follow the sudo command pattern rules.

CodeMeaningWhat to do
SUDO_SESSION_MISSING#Alpacon could not match the sudo request to an open session or its command.This sudo did not come from an open Alpacon session; run it inside an approved work session or an interactive Websh session.
WORK_SESSION_SCOPE_NOT_ALLOWED#The work session does not include sudo.This work session does not include Sudo. Add it to the session in the console; the change may need an approval. With the CLI, use alpacon work-session update --scope, and include every scope the session needs because the flag replaces the list.
SUDO_COMMAND_TOO_LONG#The command is too long to record for review.This command is too long to record, so it was refused; shorten it, then run it again. You can also put the command in a script and run the script.
SUDO_SYSTEM_USER_NOT_FOUND#Alpacon has no record of the server account running sudo.The account running this sudo is not one Alpacon knows on this server; connect with an account Alpacon manages, then run the command again. If the account should be known, ask an administrator to check it.
SUDO_ACCOUNT_BOUND_TO_APPLICATION#The Websh account is linked to an application and cannot receive sudo access in the terminal.The account this sudo runs as belongs to an application, not a person, so it cannot elevate from a terminal; run it as a command instead. Run the command with alpacon exec using the application's service token.
SUDO_NO_ACCOUNTABLE_ACTOR#No active user can be identified as responsible for this sudo request.Nobody can be held accountable for this sudo, so it was refused; run it from a session that belongs to a person with an active account. Link the server account to a user, or use a work session with an active user as its assignee.
SUDO_STEP_UP_UNAVAILABLE#The deployment does not use Auth0, so it cannot complete the required MFA check.This sudo needs an MFA check that this Alpacon deployment cannot run, so only a sudo that needs no MFA check can be allowed here. Use a work session with a sudo policy whose approval takes the place of MFA.
SUDO_PRESENCE_REQUIRED#The command needs a recent MFA check.This sudo needs a fresh identity check; complete an MFA step-up, then run the command again.
SUDO_COMMAND_NOT_AUTHORIZED#The command has no recorded user to authorize sudo for it.The sudo in this command cannot be traced to a person, so it was refused; run it as a person's command instead. Run the command from a session you signed in to.
SUDO_POLICY_MFA_REQUIRED#The matching sudo policy requires MFA, but the command has no interactive terminal for it.The sudo policy for this command needs an MFA check, which a non-interactive command cannot give; run it from an interactive terminal instead. Run it in Websh, or ask an administrator for a work-session sudo policy whose approval takes the place of MFA.
SUDO_NO_WORKSESSION_POLICY#The work session has no sudo policy matching this command.No sudo policy covers this command. Run it in a work session whose sudo patterns match it; adding a pattern to a session may need an approval. Add a matching pattern with work-session update --sudo. Match the entire command without its sudo prefix; * is the only wildcard.
WORKSPACE_SUDO_WITH_MFA_DISABLED#The workspace does not allow sudo through Alpacon.Sudo through Alpacon is turned off for this workspace, so no sudo can run until the workspace's settings allow it. Ask a Superuser to enable workspace sudo.
SUDO_APPROVAL_REQUIRED#The command needs a person's approval. At the approval gate a request was opened; at the risk gate this attempt is not waiting on one.approval gate: This command needs an approval, and an approval request for it is open; its state can be read on that request. Run the same command again once it is approved. risk gate: This command needs an approval and did not run; this attempt is not waiting on one.
SUDO_APPROVAL_PENDING#The approval wait ended, you stopped waiting with Ctrl+C, or the MFA check was not completed in time. The request stays open.The wait ended before both the approval and the identity check were done, so the command did not run. Its state can be read on the approval request. Run the same command again once it is approved.
SUDO_APPROVAL_ALREADY_WAITING#The same sudo command is already waiting for approval in another terminal.The same command is already waiting for approval in another terminal, and its state can be read on that request; wait for the answer there, or stop that wait and run the command again. To stop that wait, press Ctrl+C in the waiting terminal.
SUDO_APPROVAL_REJECTED#An approver rejected the request, or it was withdrawn or expired.The approval request for this command was rejected, withdrawn or expired, so it did not run. Its state can be read on that request. Ask the approver why it was rejected.
APPROVAL_NO_OTHER_APPROVER#Nobody but the requester can approve this request.Nobody but you could approve this request, and you cannot approve your own; it is missing an approval from someone other than you. Ask a Superuser to add another approver or an auto-approve rule.
SUDO_NO_AUTHORITY#No sudo permission or policy covers the request. At the sudo gate it is refused without waiting, as in Advisory. At the approval gate, as in Enforce, an approval request is opened and the terminal waits when possible.sudo gate: No standing sudo authority covers this command for you, so it did not run; this attempt is not waiting on an approval. approval gate: No standing sudo authority covers this command, so it waits on an approval request whose state can be read on it. Run the same command again once it is approved. In Advisory, ask an administrator for standing sudo access.
SUDO_TARGET_OTHER_PERSON#The command switches into another person's account, which is always blocked.The command switches into an account bound to another person, which is never allowed; use your own account or a shared one.
SUDO_TARGET_UNPARSED#Alpacon cannot read which account the command switches into.The account this command switches into cannot be read, so it was refused; spell the target account out plainly and run it again. For example, sudo -u deploy whoami.
SUDO_INTENT_DEVIATION#The command does not match the work session's purpose. At the approval gate an approval request was opened; at the risk gate this attempt is not waiting on one.approval gate: This command does not match its work session's declared purpose, so it waits on an approval request whose state can be read on it. Start a work session for the changed work, or run the command again once it is approved. risk gate: This command does not match its work session's declared purpose and did not run; this attempt is not waiting on an approval.
SUDO_RISK_DENIED#The workspace's access rules block the command, or it was judged too risky.The workspace's risk control refused this command, and running it again unchanged gets the same answer; it needs a different command or a change to the workspace's access rules. Ask a Superuser to review the access rules.

For the approval messages and what happens while the terminal waits, see Waiting for approval. For immediate refusals, see When nothing waits. For a deployment without Auth0, see Deployments without Auth0.

Find the console messages for sudo_session_missing, sudo_no_worksession_policy, and workspace_sudo_with_mfa_disabled in the error message reference.

Messages without a code

These messages have no code to look up. The table quotes the first sentence of the temporary-unavailability message.

MessageMeaningWhat to do
Alpacon denied this sudo command.The command was refused without a code. This includes local sudo blocked outside Websh or alpacon exec.For local sudo, run the command in Websh or ask an administrator to review the Sudo outside the web terminal setting. For a command run through Websh or alpacon exec, check the Denied tab of Privilege elevation in the web console.
Alpacon sudo authorization is unavailable; command denied.The agent did not return an authorization result before the request failed or timed out.Check that alpamon is running (systemctl status alpamon), then check the server connection and agent logs before retrying.
Alpacon authorization is temporarily unavailable (the agent is not accepting connections); command not authorized.The agent is temporarily unable to accept an authorization request. This is not a policy refusal.Wait a moment, then retry.
Alpacon sudo authorization returned an invalid response; command denied.The authorization reply could not be read.Ask an administrator to check the agent logs.
Alpacon could not determine the sudo command; denied.PAM could not identify the command to authorize.Check the command and ask an administrator to inspect the agent and PAM logs if it repeats.
Alpacon could not determine the sudo target user; denied.PAM could not identify the target account.Specify the target account clearly, for example sudo -u deploy whoami.
Alpacon could not encode the sudo command; denied.The command could not be encoded for authorization.Check that the command uses valid UTF-8 text.
Alpacon could not encode the sudo identity; denied.The account information could not be encoded for authorization.Ask an administrator to check the account names and their encoding.

Verifying the installed PAM module

The server detail page shows Sudo through Alpacon for each server:

  • Active, with the alpamon-pam version, when the module is installed.
  • Inactive, when alpamon-pam is missing.
  • Unknown, when the agent is too old to report it. Update alpamon to see the state.
  • Not applicable, when the setting is off or the server is not Linux.

This is the last state the agent reported. On Linux servers running Alpamon 2.0.2 or later, removing or changing alpamon-pam directly on the host is reflected after the next agent report. With older agents, the displayed version can remain after a removal directly on the host. When in doubt, verify on the server itself:

bash
# Debian/Ubuntu
dpkg-query -W alpamon-pam
 
# RHEL/CentOS/Rocky/Alma/Fedora, openSUSE/SLES
rpm -q alpamon-pam
Last updated: