Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google cloud ssh Permission denied (publickey,gssapi-keyex,gssapi-with-mic) [duplicate]

Every time I try to enter via SSH into my VM instance in Google Compute Engine I got this error:

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

I have attempted the steps mentioned below :

  1. Generated a ssh key using the command ssh-keygen -t rsa -f ~/.ssh/[filename] -C [username]

  2. Copied the public key into instance ssh list.

  3. And then tried to ssh the compute engine using the private key ssh -i [privatekeyname] [username]@[ipaddress]

What could be the issue or am I missing some steps?

like image 828
Pranay Das Avatar asked Dec 18 '22 23:12

Pranay Das


2 Answers

I just had this issue when trying to connect. I changed "enable-oslogin TRUE" to "enable-oslogin FALSE" in the metadata and it started working again.

like image 87
Jonathan S Avatar answered Jan 13 '23 12:01

Jonathan S


Ensure that after creating the key it has been copied correctly into the VM Instance. Sometimes during the copying of the key, either tabs, spaces or other indentation may be added into the key which will result in the key being different from the original one that was created. This is a very common failure reason. It is just not good enough to cat the key file and copy whatever you see. You have to ensure that you have copied the key without tabs, spaces or other indentation that may be added.

Double check that during the connection, with the -i option, you’re using the correct private key.

Use the -v, -vv, or -vvv options with your ssh command to further troubleshoot the issue. These options allow various verbosity levels to be activated during the ssh connection which helps in troubleshooting the issue and see exactly where the problem is.

like image 29
JMD Avatar answered Jan 13 '23 12:01

JMD