命令行参数的shell脚本的密码安全 [英] Shell script password security of command-line parameters
本文介绍了命令行参数的shell脚本的密码安全的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果我使用密码作为命令行参数,它是公共使用 PS
系统。
If I use a password as a command-line parameter it's public on the system using ps
.
但是,如果我在一个bash shell脚本和我做这样的事情:
But if I'm in a bash shell script and I do something like:
...
{ somecommand -p mypassword }
...
这是仍然要在进程列表中显示出来?或者,这是安全的吗?
is this still going to show up in the process list? Or is this safe?
- 如何子过程:(......)?不安全吧?
- 协进程?
推荐答案
命令行永远是可见的(如果只是通过/ proc中)。
Command lines will always be visible (if only through /proc).
因此,唯一真正的解决方案是:不。你可能会为它供给的标准输入,或专用FD:
So the only real solution is: don't. You might supply it on stdin, or a dedicated fd:
./my_secured_process some parameters 3<<< "b@dP2ssword"
像一个脚本(简单在前)
with a script like (simplicity first)
#!/bin/bash
cat 0<&3
(此示例将只转储一个错误的密码到stdout)
(this sample would just dump a bad password to stdout)
现在你需要去关注的是:
Now all you need to be concerned with is:
- MITM(冒牌脚本屋檐通过颠覆PATH下降的密码,例如)
- bash的历史,在命令行保留您的密码(看 HISTIGNORE 对于bash,例如。)
- 脚本包含口令重定向的安全
- <子>使用的TTY的安全;键盘记录器; ...你可以看到,我们现在已经陷入了一般安全原则
- MITM (spoofed scripts that eaves drop the password, e.g. by subverting PATH)
- bash history retaining your password in the commandline (look at HISTIGNORE for bash, e.g.)
- the security of the script that contains the password redirection
- security of the tty's used; keyloggers; ... as you can see, we have now descended into 'general security principles'
这篇关于命令行参数的shell脚本的密码安全的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文