Unable to SSH Google Cloud Engine instance through gcloud & Putty from Windows 10

5,870

OP has resolved this issue by copying his SSH keys to authorized_keys file. This issue can be caused if Google accounts daemon is not running on your VM. This daemon is responsible for syncing ssh keys and user account information between the metadata and VM. For more information on accounts daemon you can visit this link.

Share:
5,870

Related videos on Youtube

Ashutosh Agrawal
Author by

Ashutosh Agrawal

Updated on September 18, 2022

Comments

  • Ashutosh Agrawal
    Ashutosh Agrawal over 1 year

    I could do SSH & SFTP from a windows 7 laptop to my Google Compute Engine instance until I changed my laptop & also upgraded to Windows 10. In the event I lost my previous settings, so had to start it all over again. I followed the steps provided from below but couldn't succeed -

    Cannot connect to Compute Engine instance via SSH

    https://cloud.google.com/compute/docs/console#sshkeys

    Unable to SSH to Google Cloud

    My setup is same with just one change that my local machine is running on Windows 10.

    I used gcloud sdk on windows 10, which updates the first time generated public key by itself onto my cloud instance, I could verify that also.

    But the login from both gcloud & Putty fails with the error code "Disconnected: No supported authentication methods available(server sent: publickey)".

    However, I could login successfully through the Web SSH.

    What could be the issue?

    It is that I have to use my gmail account/email only (in some specific format) while generating the keys? or Windows 10 SDK compatibility issue? or something else?

    • user9517
      user9517 almost 9 years
      What do the sshd logs on your server say?
    • Ashutosh Agrawal
      Ashutosh Agrawal almost 9 years
      cat /var/log/auth.log|grep ssh shows the following..repeatedly.. Aug 9 10:27:57 test sshd[24084]: error: Could not load host key: /etc/ssh/ssh_host_ed25519_key Aug 9 10:28:00 test sshd[24084]: error: Received disconnect from 122.172.161.25: 14: No supported authentication methods available [preauth]
    • user9517
      user9517 almost 9 years
      So now you have an error message you have something to work on. I'll let you do just that.
    • Faizan
      Faizan almost 9 years
      On your windows 10 machine you can open your key in a text editor notepad or notepad++ to make sure your key is properly formatted remove extra spaces or blank lines. Moreover, have you copied the public key created for windows 10 user to GCE instance authorize_keys file or to GCE metadata server ?
    • Ashutosh Agrawal
      Ashutosh Agrawal almost 9 years
      @Faizan I didn't copy it manually anywhere. The gcloud tool automatically copies it to the GCE Metadata/SSH server. Do I need to copy it to the instance authorize_keys manually?
    • Faizan
      Faizan almost 9 years
      if your keys are in the project metadata it should sync with all the instances in your project. There is a script google-adress-manager(github.com/GoogleCloudPlatform/compute‌​-image-packages/blob‌​/…) running on the instance which is responsible to sync all the accounts and keys. Can you check if that script in running on your vm ? You also can try to copy the keys to /etc/authorized_keys to see if that works for you.
    • Ashutosh Agrawal
      Ashutosh Agrawal almost 9 years
      Thanks @Faizan!! Copying directly to /etc/authorized_keys worked. However, I checked about the google-address-manager script, it doesn't exists on my instance. Running ps -ef|grep google shows /usr/share/google/google_daemon/manage_addresses.py /usr/share/google/google_daemon/manage_accounts.py /usr/share/google/google_daemon/manage_accounts.py'
    • Faizan
      Faizan over 8 years
      I'm glad to know your issue has been resolved. Sorry my bad the script is account manager (github.com/GoogleCloudPlatform/compute-image-packages/blob/‌​…) and not address manager.