2
votes

the last days I tried my hardest to get a ssh-connection running from my home computer to a Google compute engine instance, but couldn't make it happen. Unfortunately, the search results from the internet didn't helped my either, so I will ask you guys for help :). Every answer/suggestion is highly appreciated.

.

My stats:

Home-Computer:

  • OS is Windows 7

  • Home-Computer username is not the same as my Google cloud account name

Google instance:

  • n1-standard-1, europe-west1-b
  • OS: Debian GNU/Linux 8.3 (jessie) [the default one]
  • External/Static IP: activated
  • Allowed HTTP traffic
  • Allowed HTTPS traffic

Others:

  • this is my first Google cloud experience

  • I'm still in my free trial period @ Google cloud plattform

  • I have Putty, Google SDK and Python 2.7 installed

.

What I did / tried so far:

First I tried to connect to my instance using the Google shell with the command:

gcloud compute ssh instance_name --zone europe-west1-b

The shell asked me to generate shh-keys, I answered 'Yes', and I obtained a private + public key in my C:\Users\Lodrik.ssh\ directory. However, while trying to connected I got the error message:

Fatal Error: Disconnected: No supported authentication methods available (server sent: publickey)

[Error_Pic][1] // sry, not working because I have < 10 reputation points

.

Second, I thought there might be a problem because my user-name from my Google account and my home-pc's user name differ. Therefore, I tried to shh-conntect to my instance, using my home-pc username:

gcloud compute ssh Lodrik@instance_name --zone europe-west1-b

As a results, I just got an error message (again -.-). However, this time it is was different one. A Putty shell opened with the message:

Using username "Lodrik". Server refused our key.

[Error_Pic_2][2] // sry, not working because I have < 10 reputation points

.

Finally, I searched at stackoverflow for my problem, and found this thread (similar question + answer): Cannot connect to Compute Engine instance via SSH

Hence, I followed the steps from the thread's answer:

1) I added my public key (from ~/Lodrik/.shh/) manually via the Google cloud plattform's web-dashboard

2) I copied the shown username (from this added public key) and my instance's IP address and entered them into putty (as described in the answer)

3) I tried to connected to my instance via putty

As a result, a shell window opened and asked me for my login name. However, no matter what name I enter, I'll get the error message:

Server refused our key.

Error_Pic_3

.

Questions:

  • Any ideas what I'm doing wrong?

  • Why do I have to add keys manually? Shouldn't that be automatic?

.

Thank's a lot for your help. If you need any more information, please ask. I'll be happy to provide it for you :)

.

Best regards,

Lodrik

2

2 Answers

1
votes

There is a known issue in the latest Google Cloud SDK version, where newly created keys have bad formatting which is causing SSH issues. Our engineering team is working on fixing it as a high priority. In order to workaround the issue for the time being, I would recommend downgrading the Gcloud Version, create the keys and update again. it can be done by doing the following:

1- Delete the .ssh folder created on your local machine
2- From the command line, run the following command:
gcloud components update --version 91.0.0
3- Once done, run the following command to create your keys:
gcloud compute ssh INSTANCE_NAME
NB: you might not be able to ssh but your keys will be created
4- Run the following command:
gcloud components update
5- Authenticate to your project:
gcloud auth login
6- Try to ssh again by running:
gcloud compute ssh INSTANCE_NAME

Another workaround will be to ssh from the cloud console in your browser by clicking on the SSH button next to the instance name.

UPDATE:

A Public Issue Tracker was open here, and the issue is now fixed.

0
votes

SSH connection error "No supported authentication methods available - Server refused our key" - might be caused by a wrong SSH username (it might used your Windows username to attempt login).

Follow these steps to correctly login to GCE with an SSH client:

  1. Copy the authorized SSH username from the web-console window, after pressing the SSH button in your GCE instances.

  2. Run PuttyGen to create private and public keys:

enter image description here

  1. Click 'Generate'.

  2. Enter your GCE authorized username in the 'Key comment'.

  3. Enter any passphrase to be used for the authentication.

  4. Save the private key (ppk file) on your local (private) computer.

  5. Copy ALL the content of the text under Public key.

  6. Paste it into a new SSH Key in your GCE Metadeta SSH Keys.

  7. Open Putty (or whatever SSH client you use), and create a new SSH session with:

    • IP = GCE instance external IP (if you don't see it, make sure to edit your instance and add it under "Network interfaces")
    • SSH > Auth > Private key file = The ppk file you saved before.
  8. Open the SSH session to login to your instance - You should now be prompted to enter your username and passphrase as you defined previously.