【问题标题】:Creating linux user password automatically with CloudFormation使用 CloudFormation 自动创建 linux 用户密码
【发布时间】:2021-03-18 23:58:01
【问题描述】:

我正在使用 CloudFormation 创建可以 RDP 进入的 EC2 Linux 机器。我正在运行所需的安装命令:

"Metadata" : {
            "AWS::CloudFormation::Init" : {
                "config" : {
                    "commands" : {
                        "step_a" : {
                             "command" : "install some stuff..."
                        },
                        "step_g" : {
                            "command" : "sudo yum groupinstall \"Gnome Desktop\" -y"
                        },
                        "step_h" : {
                            "command" : "sudo passwd centos"
                        },
                        "step_i" : {
                            "command" : "configure firewall to allow rdp..."
                        }
                    }
                }
            }
        }

正如你所见,在 step_h 中,我想为默认的 centos 用户设置密码。当需要用户输入时,如何自动返回默认密码值?也许有更好的方法来解决这个问题?

任何帮助将不胜感激!

【问题讨论】:

    标签: linux amazon-web-services amazon-ec2 command-line-interface amazon-cloudformation


    【解决方案1】:

    无提示设置用户密码的方法有多种。其中一些可以在herehere 中找到示例。

    但是,需要考虑的潜在问题是您将如何在模板中提供此密码?用纯文本硬编码?这是安全问题。使用NoEcho 将其作为模板参数传递?这更好但不可重现并且容易出错。使用 SSM 参数存储或 AWS Secretes Manager?这可能是最好的选择,但需要额外的设置。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-02-13
      • 1970-01-01
      • 1970-01-01
      • 2013-06-30
      • 2023-03-05
      • 1970-01-01
      • 2013-10-18
      相关资源
      最近更新 更多