tubetube tubetube - 3 months ago 28
Linux Question

Google Compute Engine DEBIAN : /etc/group setting lost after Reboot

I am using Debian GNU/Linux 8 (jessie) on Google Compute Engine.
My instance is newly created.
I had tried to add user to group by using this command

sudo adduser <username> <groupname>


or even

sudo usermod -a -G <groupname> <username>


and it worked perfectly before i reboot my systems.
After rebooting, i ran vim /etc/group but every users i assigned to that group disappear.

I also checked modified date of /etc/group. It seem that it had been modify after system reboot.

Answer

I too had this issue today on a CentOS 7 server. I couldn't understand why my usermod commands seemed to be successful, but not persistent after rebooting the instance on GCE.

I got this fix from Google, not sure why it's not documented better:

The user and groups are partially managed by "google-accounts-daemon.service", which is part the guest images packages for linux. To make an user from the project have a persistent group, you have to follow these steps.

In the following example the group 'club' is going to be amended to this file.

1- Add the users the to /etc/default/instance_configs.cfg on each instance, there is an option "group". For instance:

“groups = adm,dip,lxd,plugdev,video,club”

2- Restart the daemon after changing this file:

“sudo systemctl restart google-accounts-daemon.service”

3- Check the status of the daemon and it should show some output for the new group assigned to all users:

“sudo systemctl status google-accounts-daemon.service”
“Jul 18 07:03:37 instance-2 usermod[1523]: add 'jaw' to group 'club' 
Jul 18 07:03:37 instance-2 usermod[1523]: add 'jaw' to shadow group 'club' 
Jul 18 07:03:37 instance-2 usermod[1528]: add 'root' to group 'club' 
Jul 18 07:03:37 instance-2 usermod[1528]: add 'root' to shadow group 'club' 
Jul 18 07:03:37 instance-2 usermod[1533]: add 'lucmult' to group 'club' 
Jul 18 07:03:37 instance-2 usermod[1533]: add 'lucmult' to shadow group 'club' “