Answer Password Prompts with systemd-tty-ask-password-agent

A boot hangs on a disk passphrase nobody can see, and systemd-tty-ask-password-agent is the tool that surfaces the prompt so you can answer it. This is useful for prompts such as an encrypted disk passphrase or a certificate password that must be supplied while a system operation is running. Allow about ten minutes for a simple check.

Answering a real prompt requires access to the machine and knowledge of the secret it is requesting. This guide covers the installed Ubuntu package, systemd 255.4-1ubuntu8.17, whose command reports systemd 255. The local manual page is the authority for the examples below; behaviour and available options can differ on older systemd releases.

1. Confirm the installed command

Run the version check as your ordinary user. It does not change the system and does not need sudo:

$ systemd-tty-ask-password-agent --version
systemd 255 (255.4-1ubuntu8.17)

The package version in the example is specific to this machine. If yours differs, read the installed manual page before copying options into a script:

$ man systemd-tty-ask-password-agent

Checkpoint: the command must be present and its version must be clear. Do not use a similarly named helper from another package as a substitute.

2. List pending requests without answering them

Start with --list. It reports all currently pending system password requests and does not ask for a secret:

$ systemd-tty-ask-password-agent --list

When there are no requests, successful output is empty. On the machine used for this guide, the command returned status 0 and printed nothing. An empty result means there is nothing for this agent to display at that moment; it does not prove an operation has finished, that encryption is disabled, or that another user-facing agent is not active.

Check the exit status when using the command in a script:

$ systemd-tty-ask-password-agent --list
$ printf 'agent status: %s\n' "$?"
agent status: 0

Do not parse an empty line as a password request. Requests can disappear because they expire, are cancelled, or are answered by another agent.

3. Answer current requests on your TTY

Use --query to process all requests pending when the command starts. It asks on the calling TTY:

$ systemd-tty-ask-password-agent --query

Warning: if a request exists, read its message carefully before entering anything. The prompt may identify a device, service or certificate, but the exact wording is supplied by the component that made the request. Enter the secret only when you recognise the request and are on a trusted terminal.

A successful exit status means the agent completed its work without reporting a failure. It is not proof the secret was correct or that the original service reached its next state. Verify the operation separately, for example with the service's own status command:

$ systemd-tty-ask-password-agent --query
$ printf 'agent status: %s\n' "$?"
agent status: 0
$ systemctl status NAME.service --no-pager

Replace NAME.service with the unit you are actually investigating. The final systemctl command may need elevated privileges to show all details, but do not add sudo to the password-agent command just because a prompt mentions a system resource.

4. Keep watching during a maintenance operation

Use --watch when requests may arrive after the command starts:

$ systemd-tty-ask-password-agent --watch

The process keeps handling password requests until it is stopped. Run it in a terminal you can monitor, and use Ctrl-C once the maintenance work is complete. Do not leave a watch process running unattended, or turn it into a permanent service without first deciding who may see and answer prompts.

This mode is easy to mistake for a hung command. A quiet terminal can simply mean no request is pending. In another terminal, list the queue:

$ systemd-tty-ask-password-agent --list

Stop the watcher before closing the terminal. There is no persistent configuration to undo here; terminating the process only stops this agent instance. It does not cancel the underlying operation or remove a disk-encryption requirement.

5. Select a different delivery target

The default target for --query and --watch is the calling TTY. The manual also gives three explicit alternatives:

These are routing choices, not ways to bypass the request. For example, a console agent is useful when the terminal that started a recovery task is not the terminal attached to the machine:

$ systemd-tty-ask-password-agent --console=/dev/console

Security warning: take care with --wall. Wall messages are visible to logged-in users and are not a private password-entry interface. Do not use it for a secret unless the local setup and the request's intended security boundary explicitly justify that choice. Plymouth is also a display mechanism, not a guarantee that a graphical prompt is available.

Common traps

Done means