1
votes

I have restarted our google cloud compute engine instance, however after the restart ssh is no longer working and giving connection refused.

I have verified and the ssh keys are configured for the users, and firewall rules are open for ssh.

Is there any other method I can use to try and resolve this?

2
you should consult your server log what is written there or what reports your client in verbose mode (-vvv)Jakuje
Can you SSH in from the Developers Console by using the [SSH] button? Have you modified any configuration on the VM, such as sshd_config?Misha Brukman

2 Answers

2
votes

The first thing to do is to check the Serial console output of the machine to determine if the SSH daemon has started or not. That log can be accessed from the Developer Console.

0
votes

If you couldn't ssh to the instance you can follow the below step to access the instance from the serial console:

Connect to the instance using the serial console

1. Go to the VM instances page in Google Cloud Platform console. 
2. Click on the instance for which you want to add a startup script. 
3. Click the Edit button at the top of the page.
4. Click on ‘Enable connecting to serial ports’
5. Under Custom metadata, click Add item. 
6. Set 'Key' to 'startup-script' and set 'Value' to this script:
#! /bin/bash 
useradd -G sudo USERNAME 
echo 'USERNAME:PASSWORD' | chpasswd
7. Click Save and then click RESET on the top of the page. You might need to wait for some time for the instance to reboot. 
8. Click on 'Connect to serial port' in the page. 
9.  In the new window, you might need to wait a bit and press on Enter of your keyboard once; then, you should see the login prompt. 
10. Login using the USERNAME and PASSWORD you provided.