I am using ldapsearch
with its -y
option where the password for the ldap server is read in from a file in order to ensure that the password is not left in the command history.
ldapsearch
requires that the password be in a file with no newlines. The only way I am aware of for doing this is:
echo -n "myreallysecretpassword" > /path/to/password.txt
but obviously that puts the password in the command history, which is what I'm trying to avoid.
I assume there's a better way, could someone point me in the right direction?
Create the file however you want and just printf it without newline.
or
You can use read to input an intermediate variable semi-securely:
Of course if you're worried mostly about the command history you can disable it in bash like this: