0

I am unable to connect to the VM of a compute engine instance. My account is out of the organization, considering "a.man@company.com" as user, "wordpress-1-vm" as instance and "project-1" as project for example. My SSH key is already existing, this is the same key for other servers.

At organization level, we added the roles/compute.osLoginExternalUser to my account and enable-oslogin was set to TRUE.

Now connecting with gcloud is ok.

gcloud compute ssh --zone "us-central1-c" "wordpress-1-vm" --tunnel-through-iap --project "project-1"

From the docs, I ran the command:

gcloud compute os-login ssh-keys add --key-file="D:\Path\to\key.pub" --project=project-1 --ttl=730d

According to gcloud command, my user should be "ext_a_man_company_com".

This should work but connecting to ext_a_man_company_com@instance-ip:22 using ppk on PuTTY is returning

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

How should I connect to this server ?

NB: I also tried by adding ssh key to metadata with no success.

Jofre
  • 3,718
  • 1
  • 23
  • 31
Loenix
  • 1,057
  • 1
  • 10
  • 23
  • I would try to follow the steps described [here](https://stackoverflow.com/questions/20294381/google-server-putty-connect-disconnected-no-supported-authentication-methods-a?rq=1) – J.Vander Feb 02 '22 at 15:29
  • Which answer should I follow ? – Loenix Feb 03 '22 at 13:28
  • I would suggest to create a new pair of keys using the Puttygen and make sure that the putty peagent is configured with the proper private key and format. – J.Vander Feb 04 '22 at 11:26

1 Answers1

1

You can try troubleshooting OS Login configuration using these instructions.

If you are trying to add the key directly via VM's metadata then you need to remember to turn off OS Login for this particular VM to make it work.

Assuming both options don't work then I recommend checking your putty configuration and making sure you're using the correct user. You should be able to see what is happening in sshd logs directly on your instance (logging via console or gcloud to gain access).

  • Thank you for your help, but everyuthing seems fine by following this guide. I think this an issue with public key format. – Loenix Feb 07 '22 at 06:53
  • This was fixed using the ssh key command with right public key format, but in fact, I am sure I got several issue and I fixed it one by one with knowning what is th current problem. – Loenix Feb 07 '22 at 07:02
  • Great. Happy to hear you were able to fix it. – Remigiusz Samborski Feb 07 '22 at 12:32