nmcli is a command line interface tool for managing NetworkManager, which is a network management service in many Linux distributions. The agent subcommand of nmcli allows it to act as a NetworkManager secret agent or a polkit agent.
As a NetworkManager secret agent, nmcli is used to store and retrieve secrets such as passwords and encryption keys for network connections managed by NetworkManager. This is useful for automating tasks and scripts that need to interact with NetworkManager.
As a polkit agent, nmcli can be used to perform actions that require elevated privileges, such as enabling or disabling network connections. Polkit is a component that provides a centralized way of managing authorizations in a system. When nmcli is used as a polkit agent, it allows the user to authenticate with the polkit system and perform privileged operations without having to use the sudo command.
nmcli agent Command Examples
1. Register nmcli as a secret agent and listen for secret requests:
# nmcli agent secret
2. Register nmcli as a polkit agent and listen for authorization requests:
# nmcli agent polkit
3. Register nmcli as a secret agent and a polkit agent:
# nmcli agent all