【问题标题】:gsutil not working in GCEgsutil 在 GCE 中不起作用
【发布时间】:2013-07-11 07:50:45
【问题描述】:

因此,当我使用标准 debian 7 映像启动 GCE 实例并发出“gsutil config”命令时,它会失败并显示以下消息:

jcortez@master:~$ gsutil config Failure: No handler was ready to authenticate. 4 handlers were checked. ['ComputeAuth', 'OAuth2Auth', 'OAuth2ServiceAccountAuth', 'HmacAuthV1Handler'] Check your credentials.

我已经在 debian 6 和 centos 实例上进行了尝试,并且得到了相同的结果。但是,发出“gcutil config”可以正常工作。我收集我需要设置我的 ~/.boto 文件,但我不知道该怎么做。

我做错了什么?

【问题讨论】:

    标签: boto google-cloud-storage google-compute-engine gsutil


    【解决方案1】:

    使用E. Anderson 提及的服务帐户范围是在 Compute Engine 上使用 gsutil 的推荐方式,因此映像被配置为从 /etc/boto.cfg 中的元数据服务器获取 OAuth 访问令牌:

    [GoogleCompute]
    service_account = default
    

    如果你想自己管理 gsutil 配置,重命名 /etc/boto.cfg,gsutil config 应该可以工作:

    $ sudo mv /etc/boto.cfg /etc/boto.cfg.orig
    $ gsutil config
    This script will create a boto config file at
    /home/<...snipped...>/.boto
    containing your credentials, based on your responses to the following questions.
    <...snip...>
    

    【讨论】:

    • 谢谢布赖恩。 /etc/boto.cfg 重命名有效。正是我想要的。
    【解决方案2】:

    您是否尝试通过use a service account 访问云存储而无需输入凭据?

    听起来 gsutil 正在搜索具有适当范围的 OAuth 访问令牌,但没有找到。您可以通过在通过gcutil 启动 VM 时请求 storage-rwstorage-full 权限,或通过在 UI 控制台上的“项目访问”下选择适当的权限来确保您的 VM 可以访问 Google Cloud Storage。对于gcutil,应该可以使用以下内容:

    > gcutil addinstance worker-1 \  
    > --service_account_scopes=https://www.googleapis.com/auth/devstorage.read_write,https://www.googleapis.com/auth/compute.readonly
    

    【讨论】:

    • 我刚刚运行了一个基本的“gcutil addinstance ”命令来启动实例。如果可能,我想避免使用服务帐户选项。
    【解决方案3】:

    当您配置 GCE 实例时,您是否使用已配置的服务帐户对其进行了设置?当您在已配置服务帐户凭据的情况下尝试运行 gsutil config 时,旧版本的 gsutil 会感到困惑。

    如果您已经配置了服务帐户,则不需要运行 gsutil config - 您应该能够简单地运行 gsutil ls、cp 等(它将使用位于 ~/.boto 文件之外的其他位置的凭据) .

    如果您确实想运行 gsutil 配置(例如,设置与您的登录身份相关联的凭据,而不是服务帐户凭据),您可以尝试从 http://storage.googleapis.com/pub/gsutil.tar.gz 下载当前 gsutil,解压缩并运行它gsutil 的副本。请注意,如果您这样做,您通过运行 gsutil config 创建的个人凭据将基本上“隐藏”您的服务帐户凭据(即,如果您想再次使用您的服务帐户凭据,则需要将 .boto 文件移到一边) .

    Mike Schwartz,Google 云存储团队

    【讨论】:

    • 不,我没有创建配置了服务帐户的实例。我可能最终需要这样做,但现在想避免它。我确实使用最新的 gcutil (3.31) 运行它并且得到了相同的结果。我运行的任何 gcutil 命令都有相同的失败消息。唯一运行的是“gcutil --help”。
    • 顺便说一句,我用来创建实例的命令只是一个基本的“gcutil addinstance ”。当它出现时,我 ssh 并输入“gsutil config”(或任何 gsutil 命令),我会遇到这个失败。
    【解决方案4】:

    仅供参考,我现在正在对 gsutil 进行一些更改,以便更顺利地处理您遇到的问题。该版本应该会在接下来的一两周内发布。

    迈克

    【讨论】:

      猜你喜欢
      • 2014-08-06
      • 2014-11-07
      • 2016-01-31
      • 2019-01-19
      • 2017-10-08
      • 2014-05-24
      • 1970-01-01
      • 2023-03-08
      • 1970-01-01
      相关资源
      最近更新 更多