i am new to google cloud,i just deployed my first instance it was working fine till yesterday, i used last time to set email server using this tutorial email server, but now i am unable to connect ssh in browser and also with google cloud sdk in terminal.
Website is running fine,I don't know what happened Please help
the error message in browser
Connection Failed, and we are unable to connect VM on port 22.
the error message in terminal
Warning: Permanently added 'xxx.xxx.xxx.xxx' (ECDSA) to the list of known hosts.
Permission denied (publickey).
ERROR: (gcloud.compute.ssh) [/usr/bin/ssh] exited with return code [255].
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] –
Best Answer
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.