Connect to serial console password

Hi,

I am trying to connect to my google vm (running linux) using serial console, I followed all the instructions,

1- enabled serial console

2-add auto script in the vm (with adduser command and password)

3- reset

4- logged to the vm through serial console

5- the password is not accepted,

any help is highly appreciated.

2 Likes

Hi @mohasu ,

Welcome to Google Cloud Community!

Here are some basic troubleshooting steps you can follow:

  1. 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

  1. 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

  1. 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

  1. 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

  1. 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.

1 Like