Hi @mohasu ,
Welcome to Google Cloud Community!
Here are some basic troubleshooting steps you can follow:
- Check if Password Authentication is Enabled:
By default, Google Cloud VMs use SSH keys instead of passwords. To allow password-based access, ensure that password authentication is enabled in the SSH configuration.
- You can connect using the serial console to access boot logs, even if the password isnât working. Once connected, check the /etc/ssh/sshd_config file for configuration settings.
sudo cat /etc/ssh/sshd_config | grep -i passwordauthentication
- If the setting shows PasswordAuthentication as âno,â change it to âyes.â If youâre unable to log in, mount the disk on another VM and manually update the file.
sudo sed -i âs/^PasswordAuthentication no/PasswordAuthentication yes/â /etc/ssh/sshd_config
sudo systemctl restart sshd
- Verify the User was Created Correctly:
If the adduser command was executed in a startup script and it didnât complete properly, try running these commands to resolve the issue:
- Check if the user exists:
cat /etc/passwd | grep
- If the user is missing, manually create it:
sudo adduser
sudo passwd
- Reset Root Password and Use Root Login:
- If the password is not working, you can try resetting it for the root user:
sudo passwd root
- Then enable root login in /etc/ssh/sshd_config:
PermitRootLogin yes
- After restarting SSH, you can now try logging in as root in the serial console.
sudo systemctl restart sshd
- Use a Metadata Startup Script Instead:
Google Cloud allows you to set a startup script via metadata to ensure it runs properly. Simply add the script to the VM metadata, restart the VM, and try again.
#!/bin/bash
sudo useradd -m -s /bin/bash myuser
echo âmyuser:mypasswordâ | sudo chpasswd
- Check Logs for Authentication Failures:
To get more insight into why the login is failing, check the logs:
sudo journalctl -u sshd --no-pager | tail -20
If you need further assistance, you can reach out to Google Cloud Support at any time.
Was this helpful? If so, please accept this answer as âSolutionâ. If you need additional assistance, reply here within 2 business days and Iâll be happy to help.