Another unprivileged LXC uid/gid remap post

gelcom

Member
Mar 18, 2021
32
0
11
44
Hi all, sorry for the noob question.
I have a LXC container that I want root user and root group on CT to be mapped to uid 1015 and gid 1015 on host.

I read https://pve.proxmox.com/wiki/Unprivileged_LXC_containers and I understood that:
The first number is the id in your container.
The second number is the id being mapped from container to uid on the host.
The third number is how many consecutive ids you want to map.

According to this i set the above configuration to my LXC /etc/pve/lxc/104.conf:
lxc.idmap = u 0 1015 1
lxc.idmap = g 0 1015 1
lxc.idmap = u 1 100001 65535
lxc.idmap = g 1 100001 65535

/etc/subuid:
root:1015:1

/etc/subgid:
root:1015:1

When I do this the container starts ok but I'm unable to login as root.

What am I missing here?

kind regards
 
Hi,
at container creation, because of the default unprivileged mapping root had ID 100000. All files within the container belonging to root have this ID set. Now that you changed the map, root has ID 1015, but the files still belong to 100000. You could mount the LXC's rootfs with pct mount 104 and then change the affected file's owner and group from 1000000 to 1015 as well. Or maybe create a new user to remap instead of root, so you don't have to chown most of the file system tree.
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!