gcloud ssh — No supported authentication methods a

2020-07-22 09:43发布

问题:

I am trying to follow a simple process of ssh'ing to the instance that is described here. Unfortunately I keep getting this error:

 Server refused our key FATAL
ERROR: Disconnected: No supported authentication methods available
(server sent: publickey)

It looks like I do everything correctly.

  1. I create an new ubuntu instanse
  2. Try to log in using $ gcloud compute username@ssh example-instance --zone us-central1-a
  3. Getting a warning that ssh key is going to be generated

    WARNING: You do not have an SSH key for Google Compute Engine.
    WARNING: [C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\bin\sdk\winkeygen.exe] will be executed to generate a key.
    Updated [https://www.googleapis.com/compute/v1/projects/sharp-kayak-120708].
    
  4. I get the error mentioned above

    Server refused our key
    FATAL ERROR: Disconnected: No supported authentication methods available (server sent: publickey)
    

I see the keys created on both, local machine and instance (gcloud adds them to Metadata -> SSH keys). SSH is allowed in network settings.

I have tried an alternative route described here:

  1. generate ssh using gcloud
  2. add it to pageant
  3. SSH using PuTTY
  4. same error:

    No supported authentication methods available
        (server sent: publickey)
    

Would really appreciate your ideas.

回答1:

Thanks for the reports.

The problem is fixed in Cloud SDK Release 98.0.0. It includes remediation that recognizes corrupt Windows key files and regenerates them on the fly.

The problem was in google-cloud-sdk\bin\sdk\winkeygen.exe. It botched the public key modulus representation in the generated .ppk and .pub files. The ssh server then interpreted the modulus as a signed bignum and bailed.



回答2:

Thanks to George for assistance with work around: https://groups.google.com/forum/?utm_medium=email&utm_source=footer#!topic/gce-discussion/uAPNpkBJXi4

Step by step guide here:

  1. Download PuTTY and PuTTYgen.
  2. Generate a key with PuTTYgen. Replace the text in the comment box with your windows username. Copy and paste the code from the window into SSH keys for the project AND for the instance (go to instance, edit, scroll down to SSH key list and click "add") (not sure if both are necessary). Don't use a pass phrase.
  3. Also, save as private key file. For convenience save it in your C:\Users\.ssh folder. PuTTY will need this format of key to work.
  4. Open PuTTY. Add the key to the session: Connection>SSH>Auth>Browse.. point at the newly generated key file you just made in .ssh.
  5. Set up the session. Enter IP address. Worth saving at this point - it will remember the IP and key.
  6. Open...
  7. Log in as:... enter your Windows username that you added as the comment in the key gen.

I'm now up and running! Looking forward to a fix that lets the "google compute ssh command work! Bug report: https://code.google.com/p/google-cloud-sdk/issues/detail?id=546