gpt4 book ai didi

amazon-web-services - 如何使用 boto3 在 AWS 中禁用用户的密码

转载 作者:行者123 更新时间:2023-12-02 01:02:43 29 4
gpt4 key购买 nike

我正在使用 boto3 在 AWS 中审计用户密码,但我没有找到实现以下 CIS 基准的方法:“确保禁用 90 天或更长时间未使用的凭证(启用密码)被禁用。”

我有提取密码年龄并提取上次使用密码的代码,但我没有找到任何使密码无效的代码。

对于访问 key (但不是密码),我们有以下内容:

client = session.client('iam')

... (get user and keyid) ...

last_used = client.get_access_key_last_used(AccessKeyId=keyid)

... (determine the age of the key) ...

if age >= 90:

client.update_access_key(AccessKeyId=keyid, Status='Inactive', UserName=user)

有没有人有任何指示?

最佳答案

delete_login_profile如果您想删除指定 IAM 用户的密码,则应使用该密码,这会终止用户通过 AWS 管理控制台访问 AWS 服务的能力。

但是,为了防止所有用户访问(包括 CLI 和 API 访问),您还必须使任何访问 key 处于非事件状态或将其删除。

来自 Boto3文档:

Warning

Deleting a user's password does not prevent a user from accessing AWS through the command line interface or the API. To prevent all user access you must also either make any access keys inactive or delete them. For more information about making keys inactive or deleting them, see UpdateAccessKey and DeleteAccessKey.

关于amazon-web-services - 如何使用 boto3 在 AWS 中禁用用户的密码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49459238/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com