alper
alper

Reputation: 3390

Cannot ssh into Google-Engine, connecting in a loop

I am unable to connect through SSH to my GCE instance. I was connecting without any problem, the only think I changes was my user name through top right corner of the browser then selected Change Linux Username.

When I try to ssh into my google engine via browser, I keep having following message in a endless loop:

enter image description here

When I try to ssh via cloud shell I also get following error message, (serial console output):

Permission denied (publickey).
ERROR: (gcloud.compute.ssh) [/usr/bin/ssh] exited with return code [255].

[Q] Is there any way to fix this problem? Since I have no access to the engine now, I don't know what to do.

Upvotes: 3

Views: 808

Answers (2)

Alvaro Rodriguez Scelza
Alvaro Rodriguez Scelza

Reputation: 4174

I had the same problem, It took me several days to figure out what was happening in my case.

To find out, I created a new instance from scratch and started making all modifications I've done to those that eventually couldn't connect to, one by one, exiting the ssh connection and re entering so as to test it.

I've tried it a couple of times, in both cases, the connection was impossible after uninstalling python (I only needed 3.7 version so I was uninstalling all others and installing that one I needed).

My command for uninstalling it was sudo apt purge python2.7-minimal and sudo apt purge python3.5-minimal

I don't know if it was specifically because of deleting python, or because of using purge (in which case this problem might reproduce if using purge with another program). I don't even know why would this affect ssh connection.

Could it be that google cloud is somehow using destination python for the ssh web?

In any case, if you are experiencing this problem try to avoid uninstalling anything from the base VM.

Upvotes: 1

Alessio
Alessio

Reputation: 173

However you could always get back access through serial console then from there you could internally y troubleshoot user/ssh issue.

1) $ gcloud compute instances add-metadata [INSTANCE_NAME] --metadata=serial-port-enable=1

You can then connect to the instance through the serial port NOTE:The root password have must been already set in order to use the serial port

2)

$ gcloud compute connect-to-serial-port [INSTANCE_NAME]

If you never set the root password you could set it by adding a startup-script to your instance that will set a password as root by running the below command : NOTE: the instance must be rebooted in order to run the startup script.

3) $ gcloud compute instances add-metadata [instance name] --metadata startup-script='echo "root:YourPasswdHere" | chpasswd'

Reboot the instance run the command on the step "2)" authenticate your self as root with the password that you set on the startup script in the step "3)" .

Upvotes: 2

Related Questions