(gcloud.compute.ssh) Could not SSH into the instance

hello everyone !

before posting, i tried to find other posts whith the same problem i face but i did not find, so i hope it will not be redundant with an other post !

After having saw first video on image classification, i started to set up my Google Cloud Platform (GCP) environment. I release each step succesfully expect until command :

gcloud compute ssh --zone=$ZONE jupyter@$INSTANCE_NAME -- -L 8080:localhost:8080

Each times, i have the same error results. I used ubuntu App for Windows 10 as a terminal :

“Updating project ssh metadata…⠧Updated [https://www.googleapis.com/compute/v1/projects/my-fastai-project-6].
Updating project ssh metadata…done.
Waiting for SSH key to propagate.
jupyter@X.X.X.X: Permission denied (publickey).
ERROR: (gcloud.compute.ssh) Could not SSH into the instance. It is possible that your SSH key has not propagated to the instance yet. Try running this command again. If you still cannot connect, verify that the firewall and instance are set to accept ssh traffic.
jerome@jérôme:~$”

or

“ssh: connect to host 34.94.114.212 port 22: Connection refused
ERROR: (gcloud.compute.ssh) [/usr/bin/ssh] exited with return code [255].”

To solve this, i tried :

  • to delete and create a new instance several times from my windows computer. Besides, i tried also to create new instance from my macBook but the result was the same.
  • Disable my computer firewall
  • Add firewall rules inside GCOULD
  • init gcloud
  • telnet port 22 : seems working
  • ssh port 22 :not working.
  • I checked each time inside Metadata -> SSH , that key is well created.
  • to create ssh key with putty, save public and priivate key to my computer and adding public key inside my SSH instance

neither of these options worked, so i decided to create my jupyter environment directly from my gcloud instance with an SSH windows.

The manimulation worked because i can see with command “jupyter notebook list” the notebookj created. However, when i tried to connect to " http://:" i got an empty google chrome windows with an error message.

I’am trying to fix this issue since two days, anyone can please help ?

1 Like

@Confetti I’m having the same issue. Did you ever work it out?

I had a similar issue. I went through the exact instructions in the GCP setup guide. I finally went through the GCP guide on SSH-ing in to a box to see if I could get that to work. Using the instructions here:

https://cloud.google.com/compute/docs/instances/connecting-to-instance

I clicked on the ‘SSH’ box for my instance in the GCP console. This brought up a browser window with the SSH shell. I think doing this caused some files to get written regarding SSH keys or something because after that I was able to successfully ssh in my terminal with the given gcloud compute ssh ... command. Anyway, that’s what worked for me. Hope that helps!

1 Like

Did you try SSH-ing into your instance using the usual ssh Linux command?
Also, maybe try deleting the Gcloud private/public keys on your machine and the instance and then reinitialising your gcloud-cli. You may be able to login after that.

I had faced similar issues a few months ago, but for me, one of the solutions among the things that you have already tried worked, and it never became this problematic.

Also, one thing that would always work is trying to log in as some other user (another_user@instance-1). This would create a new user directory with all the SSH keys in their proper place. But then you’d have to login as that user each time you need to access your instance.

I am still having the same issue, and none of the above worked. Were there any other approaches that worked for anyone?