Upon creating a new Ubuntu instance on GCP (from the official 18 LTS image), I noticed that it already has a few users in the /home folder. These are user names that I've created in the past on another instance. The new instance is created from scratch, not cloned. I'm wondering why this would happen?
1 Answer
As outlined in this documentation, the google-accounts daemon in compute-image-packages creates users and home directories for all users in the project that have SSH access after booting the new instances (these accounts are registered as SSH keys in the Compute Engine metadata).
The google-accounts daemon repeatedly polls the metadata server and creates home directories, UNIX accounts, and entries in ~/.ssh/authorized_keys to allow you to login.
You should either:
Option 1. Remove those users and home directories from the instance with SSH access and disable google-accounts-daemon service.
To do this, set accounts_daemon to false in the /etc/default/instance_configs.cfg file:
[Daemons] accounts_daemon = false
Regenerate /etc/default/instance_configs.cfg configuration file:
$ sudo /usr/bin/google_instance_setup
Stop google-accounts-daemon service:
$ sudo systemctl stop google-accounts-daemon
and disable google-accounts-daemon service:
$ sudo systemctl disable google-accounts-daemon
It will prevent the GCE instance from adding accounts and the google-accounts-daemon won't start at boot.
Option 2. Switch to OS Login based SSH access to manage SSH access to Linux instances.