Thursday, 19 September 2013

How to anonymize all passwords in a file in bash

How to anonymize all passwords in a file in bash

Assume you have a large configuration file containing passwords and other
classified data. The file may change in the future. I would like to
substitute this kind of data with placeholders, e.g. *** using bash to
create a version of the current config without containing the classified
information.
The file does has the form:
user_foo="Foo"
foo_pwd=12345
user_bar="Bar"
bar_password_x=42
a.passwd=asdf
and should be transformed to
user_foo="Foo"
foo_pwd=***
user_bar="Bar"
bar_password_x=***
a.passwd=***
Some script accepting a blacklist of strings being contained on the left
side of the assignents is maybe the way to do it.
Unfortunately I am no expert in bash but maybe there is an elegant
solution based on sed or awk.

No comments:

Post a Comment