GoogleCloudPlatform / guest-agent

Apache License 2.0
130 stars 80 forks source link

Google Guest Agent Throws SSH Key Error Even Though User Has Access to Google Cloud VM #191

Open iPrOmar opened 1 year ago

iPrOmar commented 1 year ago

Steps to Reproduce (Tested on Ubuntu 20.04.02)

  1. Create a Google Cloud Engine VM with base Ubuntu 20.04
  2. The vm boots successfully
  3. Cloud-Init image completes (applied via the metadata section of Google Engine using terraform)
  4. Project-wide SSH keys added to VM (applied via the metadata section of Google Engine using terraform)
  5. The package google-guest-agent.service throws an error (see log below) saying "Invalid ssh key entry - unrecognized format" even though the said user can access the VM via SSH.

The Problem These VM instances are then used to produce a standard image template so this error is reproduced across our entire VM estate as each VM is created from this image.

It doesn't seem to affect our project-wide SSH keys from establishing an SSH session to any VMs in the Google Cloud project but it does mean that this error is being seen everywhere as it is propagated by the VM image used to generate all of our VMs.

The package version this error has been seen on is - google-guest-agent_20220622.00-0ubuntu2~20.04.0_amd64.deb

Dec  8 09:51:14 instance-1 systemd[1]: Condition check resulted in Bluetooth service being skipped.
Dec  8 09:51:14 instance-1 rtkit-daemon[1944]: Supervising 0 threads of 0 processes of 1 users.
Dec  8 09:51:14 instance-1 rtkit-daemon[1944]: message repeated 4 times: [ Supervising 0 threads of 0 processes of 1 users.]
Dec  8 09:51:14 instance-1 systemd[2036]: Started D-Bus User Message Bus.
Dec  8 09:51:14 instance-1 dbus-daemon[2060]: [session uid=1001 pid=2060] AppArmor D-Bus mediation is enabled
Dec  8 09:51:14 instance-1 systemd[2036]: Started Sound Service.
Dec  8 09:51:14 instance-1 systemd[2036]: Reached target Main User Target.
Dec  8 09:51:14 instance-1 systemd[2036]: Startup finished in 197ms.
Dec  8 09:52:01 instance-1 google_guest_agent[887]: ERROR non_windows_accounts.go:199 Invalid ssh key entry - unrecognized format: ssh-rsa <hidden_for_security_reasons>= user@user-MacBook-Pro.local
Tr1gs commented 1 year ago

We are seeing this in version: 20220622.00-0ubuntu2~18.04.1 (looks like the same tag). From here and the logs it seems like it is expecting user:ssh-rsa [KEY_VALUE] [USERNAME] but receiving ssh-rsa [KEY_VALUE] [USERNAME]