Mat*_*one 12 ssh google-cloud-platform gcloud
根据Google Cloud 文档,如果我是具有“计算实例管理员”角色的项目成员,我应该能够使用 gcloud 工具连接到项目中的任何实例。
在 Google Cloud 控制台的项目 IAM 页面上,我已明确添加具有“计算实例管理员 (v1)”角色的用户名,但我仍然无法连接到由我们的某些自动化功能创建的实例。
[username]:~/src/infrastructure$ gcloud compute ssh [instance id]
Unauthorized use is strictly prohibited. All access and activity
is subject to logging and monitoring.
Permission denied (publickey).
ERROR: (gcloud.compute.ssh) [/usr/bin/ssh] exited with return code [255].
Run Code Online (Sandbox Code Playgroud)
我似乎能够连接到的唯一实例是我创建的实例。
这里可能出了什么问题?
附带说明一下,根据此文档,我应该能够手动将 RSA 公钥添加到实例,然后使用 SSH 进行连接。
我将公钥添加~/.ssh/google_compute_engine.pub
到实例元数据中,然后尝试使用 SSH,但没有成功。
[username]:~/src/infrastructure$ ssh -i ~/.ssh/google_compute_engine [public ip of instance]
Unauthorized use is strictly prohibited. All access and activity is subject to logging and monitoring.
Received disconnect from 35.197.127.143 port 22:2: Too many authentication failures for matts
Connection to 35.197.127.143 closed by remote host.
Connection to 35.197.127.143 closed.
Run Code Online (Sandbox Code Playgroud)
正如 Google 建议的那样,我不想手动管理实例访问的 SSH 密钥。我想gcloud compute ssh
工作,所以我对第二次失败的关注不如对第一次失败的关注(除非它们相关)。
小智 9
我试图从 docker 容器通过 ssh 连接到 gcloud 上的虚拟机。运行 Docker 容器时的默认用户名为root
。
除非指定,否则该gcloud compute ssh
命令将使用本地用户名,就像 ssh 一样。现在,密钥传播似乎并不喜欢这个名字root
。唯一的指示来自机器的串行端口输出:
[ 5.621630] google_metadata_script_runner[638]: 2020/10/21 09:43:01 logging client: rpc error: code = PermissionDenied desc = The caller does not have permission
[ 5.622286] google_guest_agent[635]: 2020/10/21 09:43:01 logging client: rpc error: code = PermissionDenied desc = The caller does not have permission
Oct 21 09:43:01 private-cluster-bastion-dced90d6 google_metadata_script_runner[638]: 2020/10/21 09:43:01 logging client: rpc error: code = PermissionDenied desc = The caller does not have permission
Oct 21 09:43:01 private-cluster-bastion-dced90d6 google_guest_agent[635]: 2020/10/21 09:43:01 logging client: rpc error: code = PermissionDenied desc = The caller does not have permission
Run Code Online (Sandbox Code Playgroud)
我可以通过USER@
在机器名称中添加前缀来实现此功能,如https://cloud.google.com/sdk/gcloud/reference/compute/ssh#USER中所述
几乎任何用户名都可以。
我遇到了这个问题。我无法使用 gcloud 命令、带有 -i 标志的手动 ssh 登录,甚至无法使用网络浏览器 ssh 客户端登录。
我还尝试在 ssh 密钥编辑器中手动添加一个新密钥,这似乎很顺利,但仍然不让我进入。
增加启动磁盘大小并重新启动实例解决了该问题。
归档时间: |
|
查看次数: |
23609 次 |
最近记录: |