I cannot connect to GCE via ssh. It is showing Connection Failed, and we are unable to connect VM on port 22.
And serial console output its shows
Jul 8 10:09:26 Instance sshd[10103]: error: Could not load host key: /etc/ssh/ssh_host_ed25519_key
Jul 8 10:09:27 Instance sshd[10103]: User username from 0.0.0.0 not allowed because not listed in AllowUsers
Jul 8 10:09:27 Instance sshd[10103]: input_userauth_request: invalid user username [preauth] Jul 8 10:09:27 Instance sshd[10103]: Connection closed by 0.0.0.0 [preauth] –
Yesterday it was working fine, but today it shows this error. I am new to GCE. Any suggestions?
UPDATE
I'd like to post this update to mention that on June 2016 a new feature is released where you can enable interactive access to the serial console so you can more easily troubleshoot instances that are not booting properly or that are otherwise inaccessible. See Interacting with the Serial Console for more information.
-----------------------------------------------------------------------------------
It looks like you've added
AllowUsers
in/etc/ssh/sshd_config
configuration file.To resolve this issue, you'll need to attach the boot disk of your VM instance to a healthy instance as the second disk. Mount it, edit the configuration file and fix the issue.
Here are the steps you can take to resolve the issue:
First of all, take a snapshot of your instance’s disk, in case if a loss or corruption happens you can recover your disk.
In the Developers Console, click on your instance. Uncheck
Delete boot disk when instance is deleted
and then delete the instance. The boot disk will remain under “Disks”, and now you can attach the disk to another instance. You can also do this step usinggcloud
command:Now attach the disk to a healthy instance as an additional disk. You can do this through the Developers Console or using the
gcloud
command:SSH into your healthy instance.
Determine where the secondary disk lives:
Mount the disk:
Where
google-persistent-disk-1
is the name of the diskEdit
sshd_config
configuration file and removeAllowUsers
line and save it.Now unmout the disk:
Detach it from the VM instance. This can be done through the Developers Console or using the command below:
Now create a new instance using your fixed boot disk.