无法使用 gcloud ssh 进入实例

Cannot ssh into instance using gcloud

我已经在 gcloud 中设置了一个新实例..但是我无法使用 gcloud compute ssh instance-name 命令。详细的控制台输出是:

debug2: bits set: 511/1024
debug1: ssh_rsa_verify: signature correct
debug2: kex_derive_keys
debug2: set_newkeys: mode 1
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug2: set_newkeys: mode 0
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug2: service_accept: ssh-userauth
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug2: key: .....@..... (0x7fb5c12289f0)
debug2: key: ...../.ssh/id_rsa ((nil))
debug2: key: ...../.ssh/id_dsa ((nil))
debug2: key: ...../.ssh/id_ecdsa ((nil))
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic
debug1: Next authentication method: gssapi-keyex
debug1: No valid Key exchange context
debug2: we did not send a packet, disable method
debug1: Next authentication method: gssapi-with-mic
debug1: Unspecified GSS failure.  Minor code may provide more information
Credentials cache file '/tmp/krb5cc_1000' not found

debug1: Unspecified GSS failure.  Minor code may provide more information
Credentials cache file '/tmp/krb5cc_1000' not found

debug1: Unspecified GSS failure.  Minor code may provide more information


debug1: Unspecified GSS failure.  Minor code may provide more information
Credentials cache file '/tmp/krb5cc_1000' not found

debug2: we did not send a packet, disable method
debug1: Next authentication method: publickey
debug1: Offering RSA public key: ....@....
debug2: we sent a publickey packet, wait for reply
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic
debug1: Trying private key: ....../.ssh/id_rsa
debug1: Trying private key: ....../.ssh/id_dsa
debug1: Trying private key: ....../.ssh/id_ecdsa
debug2: we did not send a packet, disable method
debug1: No more authentication methods to try.
Permission denied (publickey,gssapi-keyex,gssapi-with-mic).

我尝试了很多方法,我发现的一种方法是将我的密钥添加到项目的元数据中..但是 Google 不应该为您做这件事吗?无论如何,它对我不起作用,我尝试在 ~/.ssh 中创建一个新的 google_cloud_compute.pub.. 仍然没有。有什么建议吗?

解决了! :)

在我的本地机器上,使用

ssh-add ~/.ssh/google_compute_engine

然后尝试了命令。工作得很好!