【问题标题】:How can I hide a secret password from being printed to the command line?如何隐藏密码不被打印到命令行?
【发布时间】:2021-08-13 03:53:33
【问题描述】:

当我运行 gradle 命令时,它会将 JAVA_TOOL_OPTIONS 值输出到命令行:

./gradlew :app:assemble
Picked up JAVA_TOOL_OPTIONS: -Dhttps.proxyUser=ME -Dhttps.proxyPassword=PASSWORD123

如果我与同事共享屏幕,这会带来安全风险,尤其是在会话被录制的情况下。我该如何解决这个问题?

注意:这些值取自全局gradle.properties

【问题讨论】:

  • 简单的答案不能解决您的问题吗?

标签: security gradle command-line terminal


【解决方案1】:

将密码写入文件,命名为proxyPassword.txt

然后使用

./gradlew :app:assemble
Picked up JAVA_TOOL_OPTIONS: 
-Dhttps.proxyUser=ME 
-Dhttps.proxyPassword=`cat proxyPassword.txt`

观看`command substitution

如果您担心您的文件不正确,可能包含更多行,您可以使用head -1 proxyPassword.txt 而不是cat

【讨论】:

    猜你喜欢
    • 2011-04-08
    • 2019-09-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-12-01
    • 2014-07-22
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多