如何解决权限被拒绝(publickey,gssapi-keyex,gssapi-with-mic)?

Boo*_*oth 10 ssh centos google-compute-engine gcloud

可能以前曾问过这个问题,但我不明白这个概念.你能帮帮我吗?

今天早上奇怪的问题..看到我只是把我的文件推到谷歌云计算然后显示下面的错误..我不知道在哪里看到该错误.

ri@ri-desktop:~$ gcloud compute --project "project" ssh --zone "europe-west1-b" "instance"
Warning: Permanently added '192.xx.xx.xx' (ECDSA) to the list of known hosts.
Permission denied (publickey,gssapi-keyex,gssapi-with-mic).
ERROR: (gcloud.compute.ssh) [/usr/bin/ssh] exited with return code [255].
Run Code Online (Sandbox Code Playgroud)

小智 9

当您的计算实例具有PermitRootLogin noSSHD配置并尝试以root用户身份登录时,会发生这种情况.您可以通过username@在实例名称之前添加来更改登录用户.这是一个完整的例子:

gcloud compute instances create my-demo-compute \
  --zone us-central1-f \
  --machine-type f1-micro \
  --image-project debian-cloud \
  --image-family debian-8 \
  --boot-disk-size=10GB

gcloud --quiet compute ssh user@hostname --zone us-central1-f
Run Code Online (Sandbox Code Playgroud)

在上面的示例中,gcloud将设置正确的凭据并确保您登录.您可以添加--quiet以忽略ssh-password问题.


小智 6

一个可能的原因是项目中的其他人为sshKeys设置了每个实例的元数据(这会覆盖项目范围的元数据).运行时gcloud compute instances describe your-instance-name,您是否看到sshKeys元数据项中调用的键?

查看最新登录的内容也会很有帮助~/.config/gcloud/logs/.但是,请务必清除敏感信息.