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 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 [preauth] – 

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:

  1. First of all, take a snapshot of your instance’s disk, in case if a loss or corruption happens you can recover your disk.

  2. 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 using gcloud command:

    $ gcloud compute instances delete NAME --keep-disks all
  3. 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:

    $ gcloud compute instances attach-disk EXAMPLE-INSTANCE --disk DISK --zone ZONE
  4. SSH into your healthy instance.

  5. Determine where the secondary disk lives:

    $ ls -l /dev/disk/by-id/google-*
  6. Mount the disk:

    $ sudo mkdir /mnt/tmp
    $ sudo mount /dev/disk/by-id/google-persistent-disk-1-part1 /mnt/tmp

Where google-persistent-disk-1 is the name of the disk

  1. Edit sshd_config configuration file and remove AllowUsers line and save it.

    $ sudo nano /mnt/tmp/etc/ssh/sshd_config
  2. Now unmout the disk:

    $ sudo umount /mnt/tmp
  3. Detach it from the VM instance. This can be done through the Developers Console or using the command below:

    $ gcloud compute instances detach-disk EXAMPLE-INSTANCE --disk DISK
  4. Now create a new instance using your fixed boot disk.

  • i am new to it i don't know how to mount and edit can you provide me link for tutorials anyway thanks hope it works Jul 9 '15 at 8:55
  • I've updated my answer with adding the steps you'll need to take to resolve the issue.
    – Kamran
    Jul 9 '15 at 17:26
  • @RahulSingh - Great to hear that your issue has been solved! Can you please accept this answer so that (a) credit is given where it’s due, and (b) the question is marked as closed? Thanks. Jul 13 '15 at 15:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.