1

我正在尝试使用 mcrpyt 或 openssl 对远程系统中的文本文件进行密码保护,但这些 shell 命令需要提示提供密码。我如何使用 ansible 使这成为可能

4

1 回答 1

1

我找到了一种使用 openssl 命令的方法

echo -n "your-password" | openssl enc -aes-256-cbc -salt -in input -out output.enc -pass stdin

解密

echo -n "your-password" | openssl enc -d -aes-256-cbc -in output.enc -out file -pass stdin

只需在 ansible 中编写这些命令,您就可以使用模板中的密码,在那里您可以使用 ansible 保险库对其进行加密

例如

echo -n "{{ password }}" | openssl enc -d -aes-256-cbc -in output.enc -out file -pass stdin

您可以从您的 var 文件中获取此密码作为变量,该文件可以使用 ansible vault 进行加密

于 2019-10-03T09:09:23.307 回答