Ubuntu Version: Ubuntu Core 26.04
Desktop Environment (if applicable): n/a (server, not a desktop)
Background:
- I’ve installed Ubuntu Core 26.04 (currently as a VM in VirtualBox to experiment, with the intention to install it on my server).
- I have created a new VM in LXD and LXC as per instructions (which, bizarrely, I can’t find now).
- I can get into the LXC VM just fine.
The situation is that the VM has only one user, specifically root. I would like to have a separate admin user, because it helps me control access via Tailscale.
I can create the admin user easily (within the LXC instance).
lxc:$~ sudo useradd --create-home --groups=sudo --shell=/bin/bash alice
Problem Description:
The problem is that when logging in as Alice in the LXC, the user cannot use sudo.
localhost:~$ sudo lxc exec ziggy -- su - alice
lxc:~$ id
uid=1001(alice) gid=1001(alice) groups=1001(alice),27(sudo)
lxc:~$ sudo true
sudo: sudo must be owned by uid 0 and have the setuid bit set
I have tried every which way that I can find to allow Alice to use sudo, but I simply cannot fix this.
Relevant System Information:
lxc~$ id root
uid=0(root) gid=0(root) groups=0(root)
lxc:~$ type sudo
sudo is hashed (/usr/bin/sudo)
lxc:~$ ls -l /usr/bin/sudo
lrwxrwxrwx 1 root root 22 Mar 13 11:02 /usr/bin/sudo -> /etc/alternatives/sudo
lxc:~$ ls -l /etc/alternatives/sudo
lrwxrwxrwx 1 root root 23 Jun 27 16:25 /etc/alternatives/sudo -> /usr/lib/cargo/bin/sudo
lxc~$ ls -l /usr/lib/cargo/bin/sudo
-rwsr-xr-x 1 root root 1082656 Mar 11 13:27 /usr/lib/cargo/bin/sudo
Question:
How do I allow Alice to use sudo?
What I’ve Tried:
I’ve followed a bunch of instructions from AI, ranging from hard-linking /usr/lib/cargo/bin/sudo to /bin/sudo, to messing with update-alternatives.
According to the AI, which of course does make mistakes, “It appears to be a namespace privilege/mapping issue unique to sudo-rs handling user transitions inside an unprivileged LXD VM container environment.”