谷歌云计算引擎操作系统登录权限被拒绝问题



在一个GCE实例上设置操作系统登录时,我收到项目新用户的Permission denied消息。

根据有关操作系统登录的 Google Cloud 文档,我已将元数据设置为enable-oslogin TRUE,并将实例中的用户的权限设置为roles/compute.osLogin,因为在此测试用例中不需要进一步的组织或服务帐户。防火墙规则也可以。

我已经启用了角色Project Editor并且它可以工作,但我不希望用户成为EditorViewer,只是通过 SSH 连接到实例并使用 Cloud IAM 对其进行管理。

这是我看到的错误:

DEBUG: Executing command: [u'/usr/bin/ssh', u'-t', u'-i', u'/home/test/.ssh/google_compute_engine', u'-o', u'CheckHostIP=no', u'-o', u'HostKeyAlias=compute.xxxxx', u'-o', u'IdentitiesOnly=yes', u'-o', u'StrictHostKeyChecking=no', u'-o', u'UserKnownHostsFile=/home/test/.ssh/google_compute_known_hosts', u'test_com@xx.xx.xx.xx']
Permission denied (publickey).
DEBUG: (gcloud.beta.compute.ssh) [/usr/bin/ssh] exited with return code [255].
Traceback (most recent call last):
File "/google/google-cloud-sdk/lib/googlecloudsdk/calliope/cli.py", line 981, in Execute
resources = calliope_command.Run(cli=self, args=args)
File "/google/google-cloud-sdk/lib/googlecloudsdk/calliope/backend.py", line 807, in Run
resources = command_instance.Run(args)
File "/google/google-cloud-sdk/lib/surface/compute/ssh.py", line 262, in Run
return_code = cmd.Run(ssh_helper.env, force_connect=True)
File "/google/google-cloud-sdk/lib/googlecloudsdk/command_lib/util/ssh/ssh.py", line 1258, in Run
raise CommandError(args[0], return_code=status)
CommandError: [/usr/bin/ssh] exited with return code [255].
ERROR: (gcloud.beta.compute.ssh) [/usr/bin/ssh] exited with return code [255].

添加下面的 IAM 角色可以解决这个问题,因此它也需要 SA 角色,这在 Google Cloud 文档中不是很清楚。

Compute OS Login
Role
Access to log in to a Compute Engine instance as a standard (non-administrator) user.
Service Account User
Role
Run operations as the service account.

您可以使用gcloud beta 计算实例 add-iam-policy-binding 命令在实例级别授予roles/compute.osLoginroles/compute.osAdminLogin角色

请参考谷歌文档

如果用户是Gmail,Yahoo等,而不是使用组织语法,则将其视为外部用户,因此您需要在组织级别将权限角色/compute.osLoginExternalUser设置为用户。

一旦它具有外部用户设置的角色,它应该可以工作。

最新更新