GCP SSH authentication has failed for Ubuntu
When you create a new Ubuntu VM instance and you try to connect via web browser you can see:
SSH authentication has failed
In logs you can see:
google_guest_agent[734]: Creating user admin.
google_guest_agent[734]: ERROR non_windows_accounts.go:144 Error creating user: useradd: group admin exists – if you want to add this user to that group, use -g..
The solution is just add Automation script with the following:
#! /bin/bash
useradd -m -G sudo mf
echo ‘mf:Pa##w0rd’ | chpasswd
sed -i “/^[^#]*PasswordAuthentication[[:space:]]no/c\PasswordAuthentication yes” /etc/ssh/sshd_config
service sshd restart