Google Cloud Engine. Permission denied (publickey,gssapi-keyex,gssapi-with-mic)

Viewed 21279

I can not connect via ssh any more, I was be able to connect for almost 24 hours. All of a sudden, ssh stops working. I had many users and I also added a new (tomcat) user in that VM.

I am get the below message when I try to ssh to my instance:

"Permission denied (publickey,gssapi-keyex,gssapi-with-mic)."

I ended up removing ~/.ssh/google_compute_engine*

Removed the 'sshKeys' metadata from Cloud Engine Console

Tried gcutil ssh again, this created new ~/.ssh/google_compute_engine file as well as sshKeys metadata.

But still I am getting that error.

8 Answers

Solution:

  1. change the you private key permission to 0600 on instance 1
  2. ssh -i /home/user/.ssh/id_rsa user2@instance-2

I tried everything above, and am still getting this error message.

This is with a new CentOS 8 VM. I have no problems with a CentOS 7 VM, it just works, and keeps on working, but the problem seems to be with CentOS 8.

I provided full information & logs here (this may be a different issue than here, but it's the same error message):

https://stackoverflow.com/questions/58430955/ssh-stops-working-on-centos-8-gce-vm-permission-denied-publickey-gssapi-keyex

Something is really wrong here with GCE, it looks like this has been happening on/off over the last 5+ years, this page has over 13K views.

Try doing this, i encountered the same problem and the below solution worked fine. Edit the "/etc/ssh/sshd_config" file on your system using vi/vim or any other editor and set "PasswordAuthentication" to yes

In my case i had to generated ssh keys using gcloud compute ssh and copy all files from ~/.ssh to the remote machine and it worked.

files genetarion:

gcloud init
gcloud compute ssh --zone "zone" "vm_name"  --project "project_name"
exit

files copy:

scp -i ~/.ssh/google_compute_engine ~/.ssh/* <user>@<IP>:~/.ssh

permissions and files check:

-rw-------. 1 your_user your_user 1161 Apr  7 07:50 /home/your_user/.ssh/authorized_keys
-rw-------. 1 your_user your_user 1679 Apr  7 07:52 /home/your_user/.ssh/google_compute_engine
-rw-r--r--. 1 your_user your_user  399 Apr  7 07:52 /home/your_user/.ssh/google_compute_engine.pub
-rw-r--r--. 1 your_user your_user  189 Apr  7 07:52 /home/your_user/.ssh/google_compute_known_hosts
-rw-r--r--. 1 your_user your_user  444 Apr  7 07:52 /home/your_user/.ssh/known_hosts

test connection :

ssh -i ~/.ssh/google_compute_engine <IP>
Related