Score:0

Is it possible to add a connection by nmcli command without sudo?

pg flag

I'm working with a lubuntu 22.04 distribution. I need to execute the following command by a user without root privileges:

> nmcli c add ifname enp3s0 type ethernet con-name 'connection-test'

The output of the previous command is the following:

Error: Failed to add 'connection-test' connection: Insufficient privileges

I have added the user to the group netdev as suggested by this post, but the problem is not solved. The post reports this sentences:

On Debian, the "netdev" group gains access to using Network Manager. On Ubuntu, Network Manager access rights are gained by being at the system console, so the name of this entry in gnome-system-tools is misleading.

The "netdev" group can administer wicd and wpasupplicant.

The "netdev" group can set the avahi host name using DBus.

The "netdev" group can administer Bluetooth devices.

This means that on Ubuntu the name of the group netdev is different?

Is it possible to be able for a not root user to execute the nmcli c add command without sudo?


This other post treats the same topic and suggests to create a service, executed with root privilege, which creates the NetworkManager connection.

uz flag
Jos
I have no answer, but it might be useful to bring up this question at the development site: https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues
Score:3
in flag

The interfaces file is part of ifupdown, which is different from the network-manager you use. network manager is part of the freedesktop 's nmcli takes it's permissions from polkit

if you create a file like this /etc/polkit-1/localauthority/90-mandatory.d/99-network.pkla, which grants users in netdev access to the networkmanager, nmcli general permissions will show you that regular users have permssions.

[Allow netdev users to modify all network states and settings]
Identity=unix-group:netdev
Action=org.freedesktop.NetworkManager.*
ResultAny=yes
ResultInactive=yes
ResultActive=yes

The original polkit answer can be found here https://unix.stackexchange.com/q/692316

frankfalse avatar
pg flag
Thank you very much: adding the file `/etc/polkit-1/localauthority/90-mandatory.d/99-network.pkla` the problem is solved.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.