JVE999
JVE999

Reputation: 3517

Cannot ssh into server except with google dev console ssh

I cannot ssh from my computer into the server hosted on Google Cloud.

I tried the normal ssh-keygen with [email protected] and uploading the public key, which worked last time, but this time it didn't. The issue started after I changed the password for the account. After that I could no longer ssh or sftp into the account, although I wasn't disconnected until I disconnected.

I then tried the gcloud ssh user@instance and it ran fine and told me it just hasn't propagated yet.

I added AllowUsers user to the server's ssh config file and I restarted ssh on the server, but still the same result

Here's the error:

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

Update:

I've been working with Google tech support and this issue is still unresolvable. A file called authorized_keys permissions keep getting changed on boot to another user, who I also cannot log in as.

So I change it to:

thisUser:www-data 755 

but on boot it changes it to:

otherUser:otherUser 600

Upvotes: 0

Views: 1383

Answers (2)

Dave
Dave

Reputation: 11

I solved this by deleting the existing ssh key under Custom metadata in the VM settings. I then could login on ssh

Upvotes: 1

Marius I
Marius I

Reputation: 1481

There are a couple of things in order to fix this. You can take advantage of the metadata feature in GCE and add a startup script that would automatically change the permissions.

  1. From the developers console, go to your Instance > Metadata and add a pair of Key/value

    key : startup-script

    value: chmod 755 /home/your_user/.ssh/authorized_keys OR chmod 755 ~/.ssh

  2. after rebooting you should check the Serial Ouput option further down that page and see if it ran on startup. it should show you something along these lines :

    startup script found in metadata.

    startupscript: Running startup script /var/run/google.startup.script

Further information can be found HERE

Hope that helps!

Upvotes: 1

Related Questions