我想创建一个EC2 linux用户,在指定的持续时间内或在使用指定的数据单元之后拥有访问权限,在此之后,用户帐户应该过期。如何设置用户账号的自动过期?
目的是为用户提供EC2 linux实例上的个人训练账号,该账号在指定时间或消费指定数据后过期,以控制成本。
任何关于这方面的帮助或建议都将是非常值得感谢的。
发布于 2015-12-07 15:15:09
您可以通过使用useradd的--expiredate选项来控制用户帐户的有效时间。
useradd(8)手册页
-e, --expiredate EXPIRE_DATE
The date on which the user account will be disabled. The date is
specified in the format YYYY-MM-DD.
If not specified, useradd will use the default expiry date specified
by the EXPIRE variable in /etc/default/useradd, or an empty string
(no expiry) by default.您可以使用此命令指定从现在起30天后的日期。
useradd -e `date -d "30 days" +"%Y-%m-%d"` username调整其到期日期
chage -E `date -d "30 days" +"%Y-%m-%d"` usernamehttps://stackoverflow.com/questions/34127604
复制相似问题