3 ms·
In ~/.bash_functions $ loz QUERY will give the password from the ~/.passwords flat text database, last password is valid one. $ lozinka will ask for que
by rcdwealth 8y ago
In ~/.bash_functions
$ loz QUERY
will give the password from the ~/.passwords flat text database, last password is valid one.
$ lozinka
will ask for questions and enter it into ~/.passwords
I suggest chattr +a ~/.passwords so that file cannot be deleted, only appended.
function loz () {
PASSWORDS=~/.passwords;
if [[ "$1" ]]; then
/bin/grep -i --color=auto "$1" $PASSWORDS;
else
echo "No query given."
fi
}
function lozinka () {
passwords=~/.passwords
echo -n "Hostname:"; read hostname;
echo -n "Service:"; read service;
echo -n "Username:"; read username;
echo -n "Email:"; read email;
password=$(pwgen -n -n -n -s 20 1)
echo -n "Password (${password}):"; read password1;
if [[ $password1 ]]; then
password=$password1
fi
if [[ ( $username || $email ) && $password ]]; then
line=$(join_by : $hostname $service $username $email $password);
echo $line >> $passwords;
tail -n1 $passwords;
else
echo "Nothing recorded as there is no username or email";
fi
}