对于我的 bash 脚本,我使用 read -s
来隐藏用户输入的密码。脚本运行后,我使用 history
命令查看是否显示任何密码,但没有。后来我知道了另一种历史,csh 历史。我似乎无法弄清楚如何查看这段历史。
如果它确实出现在 csh 历史记录中,我该如何隐藏用户输入,使其不显示在我的 linux 机器上的所有历史记录中。
最佳答案
csh 只是另一个 shell,是 bash 的替代品。所以它的历史只有在有人真正使用它时才重要。如果您的脚本不在命令行上使用密码,那么从 csh 运行时也应该没问题。但是你可以测试它:
$ csh <-- launches an interactive csh
$ ./script.sh <-- run your script
<whatever>
$ history <-- this will show you the csh history
...
$ exit <-- drops you out of csh and back to your previous shell
因此,如果该历史记录中没有任何相关内容出现,那么您就没事了。
关于linux - 在 Linux 中从命令行隐藏密码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29805646/