允许外部用户 start/stop Google Compute Engine VM 实例
Allow external user to start/stop Google Compute Engine VM instance
我有一个 Google Cloud Compute Engine 实例,我在其中创建了一个新用户(通过 adduser
)以允许开发人员在该实例中工作。现在他有 SSH 访问权限并且可以登录实例,但我希望他能够 start/stop 实例,这样当他不在实例上工作时它不会 运行 以防止在它空闲时充电。理想情况下,他可以安装 gcloud
并且只安装 运行 gcloud compute instances start/stop
命令,但不能安装其他命令
我查看了 IAM 角色,似乎没有计算实例用户角色。是否可以授予外部用户此权限?
可以,只要他们有任何类型的 Google 帐户。 Here's how to do it; indeed, it looks like you'll want to create a custom IAM role and give them instances.reset
, instances.start
, and instances.stop
在有问题的实例上。
Cloud Identity might be the right tool to use to grant them access if they're not in your company; more info here.
顺便说一句,adduser
不是允许额外用户访问实例的正确方法; OS Login is the right tool for the job. (There's also another, now-deprecated, method: adding their SSH key to the instance metadata).
我有一个 Google Cloud Compute Engine 实例,我在其中创建了一个新用户(通过 adduser
)以允许开发人员在该实例中工作。现在他有 SSH 访问权限并且可以登录实例,但我希望他能够 start/stop 实例,这样当他不在实例上工作时它不会 运行 以防止在它空闲时充电。理想情况下,他可以安装 gcloud
并且只安装 运行 gcloud compute instances start/stop
命令,但不能安装其他命令
我查看了 IAM 角色,似乎没有计算实例用户角色。是否可以授予外部用户此权限?
可以,只要他们有任何类型的 Google 帐户。 Here's how to do it; indeed, it looks like you'll want to create a custom IAM role and give them instances.reset
, instances.start
, and instances.stop
在有问题的实例上。
Cloud Identity might be the right tool to use to grant them access if they're not in your company; more info here.
顺便说一句,adduser
不是允许额外用户访问实例的正确方法; OS Login is the right tool for the job. (There's also another, now-deprecated, method: adding their SSH key to the instance metadata).