Google Compute Engine:尝试连接到实例时出现 SSH 错误

Google Compute Engine: SSH-Error while trying to connect to an instance

最后几天,我尽最大努力从我的家用计算机获得 ssh 连接 运行 到 Google 计算引擎实例,但无法实现。不幸的是,互联网上的搜索结果对我也没有帮助,所以我会向你们寻求帮助:)。每个 answer/suggestion 都受到高度赞赏。

.

我的数据:

家用电脑:

Google 实例:

其他:

.

到目前为止我做了/尝试了什么:

首先,我尝试使用 Google shell 和命令连接到我的实例:

gcloud compute ssh instance_name --zone europe-west1-b

shell 要求我生成 shh-keys,我回答 'Yes',我在我的 C:\Users\Lodrik.ssh 中获得了一个私钥 + public \ 目录。但是,在尝试连接时我收到错误消息:

Fatal Error: Disconnected: No supported authentication methods available (server sent: publickey)

[Error_Pic][1] // 抱歉,无法正常工作,因为我的声望点数小于 10

.

其次,我认为可能有问题,因为我的 Google 帐户的用户名和我家用电脑的用户名不同。因此,我尝试使用我的 home-pc 用户名 shh-conntect 连接到我的实例:

gcloud compute ssh Lodrik@instance_name --zone europe-west1-b

结果,我刚收到一条错误消息(再次 -.-)。然而,这一次是不同的一次。 Putty shell 打开并显示消息:

Using username "Lodrik". Server refused our key.

[Error_Pic_2][2] // 抱歉,无法正常工作,因为我的声望点数小于 10

.

最后,我在 Whosebug 上搜索了我的问题,并找到了这个线程(类似问题 + 答案):Cannot connect to Compute Engine instance via SSH

因此,我按照线程的回答中的步骤操作:

1) 我通过 Google 云平台的网络仪表板

手动添加了我的 public 密钥(来自 ~/Lodrik/.shh/)

2) 我复制了显示的用户名(从这个添加的 public 密钥)和我的实例的 IP 地址,并将它们输入腻子(如答案中所述)

3) 我尝试通过 putty

连接到我的实例

结果打开一个shellwindow问我登录名。但是,无论我输入什么名称,我都会收到错误消息:

Server refused our key.

Error_Pic_3

.

问题:

.

非常感谢您的帮助。如果您需要更多信息,请询问。我很乐意为您提供:)

.

此致,

洛德里克

最新的 Google Cloud SDK 版本中存在一个已知问题,新创建的密钥格式错误,这会导致 SSH 问题。我们的工程团队正在努力将其作为高优先级进行修复。为了暂时解决这个问题,我建议降级 Gcloud 版本,创建密钥并再次更新。可以通过执行以下操作来完成:

1- Delete the .ssh folder created on your local machine
2- From the command line, run the following command:
gcloud components update --version 91.0.0
3- Once done, run the following command to create your keys:
gcloud compute ssh INSTANCE_NAME
NB: you might not be able to ssh but your keys will be created
4- Run the following command:
gcloud components update
5- Authenticate to your project:
gcloud auth login
6- Try to ssh again by running:
gcloud compute ssh INSTANCE_NAME

另一种解决方法是通过单击实例名称旁边的 SSH 按钮从浏览器中的 cloud console 进行 ssh。

更新:

一个 Public 问题跟踪器已打开 here,问题现已解决。

SSH 连接错误 "No supported authentication methods available - Server refused our key" - 可能由错误的 SSH 用户名引起(它可能使用您的 Windows 用户名尝试登录)。

按照以下步骤使用 SSH 客户端正确登录 GCE:

  1. GCE instances.

  2. 中按下 SSH 按钮后,从 Web 控制台 window 复制授权的 SSH 用户名
  3. 运行 PuttyGen 创建私钥和 public 密钥:

  1. 单击'Generate'。

  2. 在'Key comment'.

  3. 中输入你的GCE授权用户名
  4. 输入用于身份验证的任何密码。

  5. 将私钥(ppk 文件)保存在本地(私人)计算机上。

  6. 复制Public键下的所有文本内容。

  7. 将其粘贴到您 GCE Metadeta SSH Keys 的新 SSH 密钥中。

  8. 打开 Putty(或您使用的任何 SSH 客户端),并创建一个新的 SSH 会话:

    • IP = GCE实例外网IP(如果没看到,一定要edit your instance加在"Network interfaces"下)
    • SSH > Auth > 私钥文件=你之前保存的ppk文件。
  9. 打开 SSH 会话以登录您的实例 - 现在应该提示您输入您之前定义的用户名和密码。