I would like to keep sensitive data such as user's e-mail address in MySQL database in encrypted form.
Is it possible to encrypt/decrypt mail column in MySQL using ssh-key forwarded by ssh-agent on the fly while using mysql monitor or performing SQL queries? I have never seen such plugin or patch so I guess not but it is worth asking.
How can I use ssh-agent inside the script (perl/bash) to decrypt column value which has been encrypted with my public ssh key?
I would appreciate any hints.
By the way that would be a great idea to have a MySQL function to do so:
SELECT user, SSH_DECRYPT(mail) FROM users;
and SSH_DECRYPT uses ssh-agent defined somewhere, for example in /etc/mysql/my.cnf. Or even better:
SELECT user, SSH_DECRYPT(mail, '/var/run/ssh-agent/users-key.sock');