我正在使用带-y选项的ldapsearch ,其中从文件读入ldap服务器的密码以确保密码不会留在命令历史logging中。
ldapsearch要求密码在没有换行符的文件中。 我知道这样做的唯一方法是:
echo -n "myreallysecretpassword" > /path/to/password.txt
但显然这将密码放在命令历史logging中,这正是我想要避免的。
我认为还有更好的办法,有人能指出我的方向吗?
创build文件,但是你想要的只是没有换行printf它。
猫pw.txt | awk'{printf $ 1}'
要么
printf`猫pw.txt`
您可以使用read来半安全地input一个中间variables:
read -s tempvar # enter your password and press enter - it will not echo back echo -n $tempvar > pw.txt unset tempvar
当然,如果你主要关心命令历史,你可以像这样在bash中禁用它:
export HISTFILE=