Google cloud platform GCP OS登录创建用户\u域帐户
我正在测试OS登录,并使用元数据“enable-oslogin=TRUE”创建了一个实例。然后我将OS登录角色添加到我的帐户(user@mydomainname.com). 当我尝试时:Google cloud platform GCP OS登录创建用户\u域帐户,google-cloud-platform,google-compute-engine,Google Cloud Platform,Google Compute Engine,我正在测试OS登录,并使用元数据“enable-oslogin=TRUE”创建了一个实例。然后我将OS登录角色添加到我的帐户(user@mydomainname.com). 当我尝试时: user@original_host$ gcloud compute ssh my_instance --project my_project --zone my_zone user@original_host$ ssh user_mydomainname@my_instance, it allowed me
user@original_host$ gcloud compute ssh my_instance --project my_project --zone my_zone
user@original_host$ ssh user_mydomainname@my_instance, it allowed me login, but as user_mydomainname of course.
GCP允许我登录,但作为用户\u mydomainname而不是我的原始帐户“用户”
当我尝试时:
user@original_host$ gcloud compute ssh my_instance --project my_project --zone my_zone
user@original_host$ ssh user_mydomainname@my_instance, it allowed me login, but as user_mydomainname of course.
user@original_host$ssh my_实例,它拒绝了我的登录
当我尝试时:
user@original_host$ gcloud compute ssh my_instance --project my_project --zone my_zone
user@original_host$ ssh user_mydomainname@my_instance, it allowed me login, but as user_mydomainname of course.
我从谷歌上读了一堆操作系统登录文档,却找不出原因。在一份文件中:
在预期登录行为
部分,它如下所示“如果用户名不是由G套件管理员设置的,OS Login将通过将用户名和与用户的Google配置文件相关联的电子邮件中的域组合起来,生成默认的Linux用户名。这种命名约定确保了唯一性。例如,如果与Google配置文件关联的用户电子邮件是user@example.com,则生成的用户名为user\u example\u com。“
这看起来像我得到的,但我已经将OS登录角色设置为我的帐户
我希望通过OS登录角色设置,我可以作为我的原始帐户登录到实例:user
我在这里遗漏了什么吗?或者这确实是预期的行为?是否可以让我的帐户“user”使用操作系统登录而不获取user\u mydomainname
谢谢,
Philip用户名等设置取自目录API。相关文档页面如下:
有关更多详细信息,您可能希望查看链接到此处的目录API的文档。首先,我尝试通过以下方式检查测试VM上的it OS登录功能:
$ gcloud compute instances create os-login-instance-1 --machine-type=n1-standard-1 --zone=europe-west3-a
Created [https://www.googleapis.com/compute/v1/projects/test-prj/zones/europe-west3-a/instances/os-login-instance-1].
NAME ZONE MACHINE_TYPE PREEMPTIBLE INTERNAL_IP EXTERNAL_IP STATUS
os-login-instance-1 europe-west3-a n1-standard-1 10.156.15.226 35.XXX.236.XXX RUNNING
$ ssh username_domain_com@35.242.236.114
Linux os-login-instance-1 4.9.0-12-amd64 #1 SMP Debian 4.9.210-1 (2020-01-20) x86_64
The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Creating directory '/home/username_domain_com'.
username_domain_com@os-login-instance-1:~$
$ gcloud compute ssh os-login-instance-1
Linux os-login-instance-1 4.9.0-12-amd64 #1 SMP Debian 4.9.210-1 (2020-01-20) x86_64
The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Mon Feb 17 12:32:56 2020 from 104.132.189.65
username_domain_com@os-login-instance-1:~$ whoami
username_domain_com
$ cloud compute instances add-metadata os-login-instance-1 --metadata enable-oslogin=TRUE --zone=europe-west3-a
Updated [https://www.googleapis.com/compute/v1/projects/test-prj/zones/europe-west3-a/instances/os-login-instance-1].
角色/compute.osadminusername@domain.com要使其能够使用sudo
命令:
$ gcloud projects add-iam-policy-binding test-prj \
--member='user:username@domain.com' \
--role='roles/compute.osAdminLogin'
Updated IAM policy for project [test-prj].
角色/compute.osLogin
进行非root访问
$ ssh-keygen
Generating public/private rsa key pair.
gcloud compute os-login ssh-keys add --key-file .ssh/id_rsa.pub
$ gcloud compute instances create os-login-instance-1 --machine-type=n1-standard-1 --zone=europe-west3-a
Created [https://www.googleapis.com/compute/v1/projects/test-prj/zones/europe-west3-a/instances/os-login-instance-1].
NAME ZONE MACHINE_TYPE PREEMPTIBLE INTERNAL_IP EXTERNAL_IP STATUS
os-login-instance-1 europe-west3-a n1-standard-1 10.156.15.226 35.XXX.236.XXX RUNNING
$ ssh username_domain_com@35.242.236.114
Linux os-login-instance-1 4.9.0-12-amd64 #1 SMP Debian 4.9.210-1 (2020-01-20) x86_64
The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Creating directory '/home/username_domain_com'.
username_domain_com@os-login-instance-1:~$
$ gcloud compute ssh os-login-instance-1
Linux os-login-instance-1 4.9.0-12-amd64 #1 SMP Debian 4.9.210-1 (2020-01-20) x86_64
The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Mon Feb 17 12:32:56 2020 from 104.132.189.65
username_domain_com@os-login-instance-1:~$ whoami
username_domain_com
user@example.com
,然后他们的
生成的用户名是user\u example\u com
我能够连接到虚拟机,但是使用username\u domain\u com
name
让我们看一下如何将username\u domain\u com
更改为username
的文档:
G套件组织可以选择更改其默认设置以删除
新生成的用户名的域名后缀。例如,如果
与谷歌个人资料相关联的用户电子邮件是user@example.com
,
然后,他们生成的用户名是user
。有关更多信息,请参阅
您还可以找到它以这种方式工作的更多细节:
OS登录将您的Linux用户帐户绑定到您的Google身份,以便
在中,您具有一致的用户名、UID和其他posix信息
您登录的每个VM。这允许VM授权您登录
使用IAM权限,以便您可以轻松撤销访问权。
posix信息对于消费者身份是不可变的(非G套件
用户)。这可以防止坏演员在游戏中设置信息
项目所有者无法管理的恶意方式。为了防止
不同组织之间的唯一性冲突(user@gmail.com
和user@example.com
)默认情况下包含域名
因此,您可以使用
username
而不是username\u domain.com
作为您的G套件组织,如果您是个人客户,则不能使用。关系是什么(如果有的话)在帐户之间<代码>user@mydomainname.com和承载计算引擎的GCP项目?例如,此帐户是否由GSuite或Cloud Identity Manager管理,而后者是项目的组织?此用户在操作系统登录方面的IAM权限(如果有)授予了计算引擎什么?如果启用了操作系统在更改Serhii回答中提到的G套件设置之前,您必须使用包含域的POSIX用户名。此API调用是当前修改POSIX用户名以进行OS登录的唯一方法。