【问题标题】:boto exception when using beeswithmachineguns with .pem [closed]将beeswithmachineguns与.pem一起使用时出现boto异常[关闭]
【发布时间】:2012-12-07 20:01:50
【问题描述】:

所以我正在尝试使用带有机枪的蜜蜂来加载测试我自己的网站。

01:01:11 Peters-MacBook-Pro:.ssh peterconerly$ bees up -k amazonkeypair -s 1 -g public -l ec2-user
Connecting to the hive.
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/2.7/bin/bees", line 5, in <module>
    main.main()
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/beeswithmachineguns/main.py", line 127, in main
    parse_options()
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/beeswithmachineguns/main.py", line 111, in parse_options
    bees.up(options.servers, options.group, options.zone, options.instance, options.login, options.key)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/beeswithmachineguns/bees.py", line 93, in up
    ec2_connection = boto.connect_ec2()
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/boto/__init__.py", line 135, in connect_ec2
    return EC2Connection(aws_access_key_id, aws_secret_access_key, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/boto/ec2/connection.py", line 87, in __init__
    https_connection_factory, path)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/boto/connection.py", line 638, in __init__
    debug, https_connection_factory, path)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/boto/connection.py", line 281, in __init__
    host, config, self.provider, self._required_auth_capability())
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/boto/auth.py", line 308, in get_auth_handler
    'Check your credentials' % (len(names), str(names)))
boto.exception.NoAuthHandlerFound: No handler was ready to authenticate. 1 handlers were checked. ['QuerySignatureV2AuthHandler'] Check your credentials

我直接用boto试了一下,按照http://www.synctus.com/blog/2010/04/securing-access-to-amazon-ec2-with-fingerprint-verification

>>> import boto.ec2
>>> conn = boto.ec2.connect_to_region('eu-west-1')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/boto/ec2/__init__.py", line 53, in connect_to_region
    for region in regions(**kw_params):
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/boto/ec2/__init__.py", line 38, in regions
    c = EC2Connection(**kw_params)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/boto/ec2/connection.py", line 87, in __init__
    https_connection_factory, path)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/boto/connection.py", line 638, in __init__
    debug, https_connection_factory, path)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/boto/connection.py", line 281, in __init__
    host, config, self.provider, self._required_auth_capability())
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/boto/auth.py", line 308, in get_auth_handler
    'Check your credentials' % (len(names), str(names)))
boto.exception.NoAuthHandlerFound: No handler was ready to authenticate. 1 handlers were checked. ['QuerySignatureV2AuthHandler'] Check your credentials
>>> 

【问题讨论】:

  • 可怜的宝宝被剥夺了睡眠。我为这个问题搜索的所有答案都是关于 AWS 密钥,而不是使用带有 pem 文件的 boto。在我提供凭据之前,它立即失败了——如果你看一下 python 解释器。

标签: python amazon-ec2 boto


【解决方案1】:

正如错误消息所示,boto 无法找到任何要使用的凭据。它位于以下位置:

  • 您可以在调用 connect_to_region 时将它们显式传递为 aws_access_key_idaws_secret_access_key
  • 可以设置环境变量AWS_ACCESS_KEY_IDAWS_SECRET_ACCESS_KEY
  • 您可以创建一个 boto 配置文件(有关详细信息,请参阅 this)并将该文件放在 /etc/config~/.boto 中,或者您可以将其放在任何您想要的位置并将环境变量 BOTO_CONFIG 设置为指向它。
  • 如果您使用IAM Roles,boto 将在 EC2 服务器上的实例元数据中找到凭据。

【讨论】:

  • 谢谢 garnaat-- 但我正在尝试将 boto 与 .pem 文件一起使用,而不是与 accesskeyid/secretaccesskey 组合一起使用。此外,在 python 解释器中,boto 在需要凭据之前的步骤失败。
  • @Civilian - 关于后者:正如错误消息所示,调用 boto.ec2.connect_to_region() 已经需要凭据(正如人们所期望的那样);你怎么认为它在步骤之前失败了它需要凭据(实际上除了无辜的import boto.ec2语句之外没有其他任何东西)?
  • @Civilian - 关于前者:使用 AWS 命令​​行工具和旧证书/密钥身份验证方案已被弃用,并将在某个时候删除;请考虑切换到同时无处不在的access key ID/secret access key 方法 - 您的生活会更轻松(如果与AWS Identity and Access Management (IAM) 结合使用,则更安全)。
  • Boto 不支持 SOAP,因此不支持通过证书文件进行身份验证。您必须在 boto 中使用 access_key/secret_key 组合。
  • 另外,connect_to_region,对于 EC2 连接对象确实需要凭据,因为它调用 DescribeRegions 请求来获取 EC2 服务当前支持的区域列表。
猜你喜欢
  • 2020-03-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多