我有一个脚本,它读取-p给一个名为PASSWD的variables:
smbclient -L 192.1.1.1 -U username%$PASSWD
我相信在历史上我将无法看到这一点。 在这个链接,它说,有人做ps将能够看到密码string? 将参数安全地传递给脚本
但是,如果一个脚本持续一个微不足道的时间(几毫秒),这不是一件大事吗?
你可以阅读man smbclient :
-U|--user=username[%password] Sets the SMB username or username and password. If %password is not specified, the user will be prompted. The client will first check the USER environment variable, then the LOGNAME variable and if either exists, the string is uppercased. If these environmental variables are not found, the username GUEST is used. A third option is to use a credentials file which contains the plaintext of the username and password. This option is mainly provided for scripts where the admin does not wish to pass the credentials on the command line or via environment variables. If this method is used, make certain that the permissions on the file restrict access from unwanted users. See the -A for more details.
所以,最好使用-A选项,并在文件上设置正确的权限,以便它不是全球可读的
如果使用密码的命令是从脚本中调用的,那么这个命令将不在你的shell历史logging中,这是正确的。 这与“subshell”无关。
但是,在任何地方存储或重新使用明文密码都不是很安全。
这是开放的讨论,它是一样安全的,你认为它是。
有些人会认为这是一个安全风险,其他人会觉得这是微不足道的。
我个人不会这样做。