Unable to execute GCP gsutil command in Windows 11 CLI.

huangapple go评论84阅读模式
英文:

Unable to execute GCP gsutil command in Windows11 CLI

问题

我正在尝试在Windows11命令行界面中执行gsutil命令

以下是命令和相关错误信息:

  1. gsutil ls
ServiceException: 401 匿名调用者无权访问Google Cloud项目的storage.buckets.list权限。对资源的权限"storage.buckets.list"被拒绝(或者它可能不存在)。
  1. gsutil mb [BUCKET NAME]
正在创建[BUCKET NAME]...
您正在尝试访问受保护的数据,但没有配置的凭据。请访问https://cloud.google.com/console#/project并注册一个帐户,然后运行"gcloud auth login"命令以配置gsutil使用这些凭据。
*注意:我在执行"gcloud auth login"后尝试过这个,登录成功。*

**我的IAM管理员角色具有以下存储权限:**
[![Admin Owner权限][1]][1]

我不确定已经完成了什么操作,整个过程在Google控制台中运行良好。是否有人可以帮助我解决这个问题?

***在此提前感谢那些伸出援手的人。***

我尝试过的方法:
- 安装了Google SDK
- 运行了`gcloud init`
- 运行了`gcloud auth login` -> 成功
- 运行了`gsutil命令` -> 失败

[1]: https://i.stack.imgur.com/T5hAT.png

<details>
<summary>英文:</summary>

I am trying to execute **gsutil commands** in Windows11 CLI.

I am providing you the command and relevant error:

1. `gsutil ls`

ServiceException: 401 Anonymous caller does not have storage.buckets.list access to the Google Cloud project. Permission 'storage.buckets.list' denied on resource (or it may not exist).


2. `gsutil mb [BUCKET NAME]`

Creating [BUCKET NAME]...
You are attempting to access protected data with no configured
credentials. Please visit https://cloud.google.com/console#/project
and sign up for an account, and then run the "gcloud auth login"
command to configure gsutil to use these credentials.

*Note: I have tired this after executing `gcloud auth login` and the login was successful.*


**My IAM admin roles has the following storage permissions:**
[![Admin Owner permission][1]][1]

I am not sure what have been done with this and the entire things works fine in the google console. Can anyone helps me in solving this issue.

***Thank you in advance to those who lend a hand with this.***

Things I tried:
- Installed Google SDK
- Run `gcloud init`
- Run `gcloud auth login` -&gt; Successful
- Run `gsutil command` -&gt; Failed


  [1]: https://i.stack.imgur.com/T5hAT.png

</details>


# 答案1
**得分**: 0

The problem is simple, I tried to look into my `gcloud` configuration.
```shell
gcloud config list

Output

[accessibility]
screen_reader = True
[compute]
region = us-central1
zone = us-central1-c
[core]
account = [ACCOUNT]
disable_usage_reporting = False
pass_credentials_to_gsutil = False
project = [PROJECT_ID]

The pass_credentials_to_gsutil was set to False and I changed it into True using the following command.

gcloud config set pass_credentials_to_gsutil True

Voila, now able to list and create buckets from my Windows11 CLI.

英文:

The problem is simple, I tried to look into my gcloud configuration.

gcloud config list

Output

[accessibility]
screen_reader = True
[compute]
region = us-central1
zone = us-central1-c
[core]
account = [ACCOUNT]
disable_usage_reporting = False
pass_credentials_to_gsutil = False
project = [PROJECT_ID]

The pass_credentials_to_gsutil was set to False and I changed it into True using the following command.

gcloud config set pass_credentials_to_gsutil True

Voila, now able to list and create buckets from my Windows11 CLI.

huangapple
  • 本文由 发表于 2023年5月13日 10:31:07
  • 转载请务必保留本文链接:https://go.coder-hub.com/76240846.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定