Email – How to Automatically Encrypt, Sign, and Forward Root’s Email

emailencryptionnetbsdroot

I've recently been teaching myself about the BSDs and decided to pick up a NetBSD VPS. I don't always log in to this box every day (it's not actually doing anything that important), but I'd still like to monitor root's mail. To that end, I started looking into how to forward root's mail to an external account. I learned a little about the /etc/aliases file, and it looks like I might be able to build up a pipeline to do this for me, but I'm treading into unfamiliar territory.

Is there a tutorial that covers this sort of thing? Is it even a good idea?

Thanks.

Best Answer

You could create a normal user, e.g. juser, and add it to the /etc/aliases file on the right hand side of the root entry.

For normal forwarding of root-mail you would just create a .forward (which contains your external e-mail address) in the home directory of juser.

Regarding encryption you can use a MDA (mail delivery agent for that), e.g. procmail and for that. Instead of a .forward you have to create a .procmailrc file in the home directory of juser in that case.

Via .procmailrc you can pipe a message (header/body) through an external program, e.g. a simple script that basically contains some gpg command. And with the right rule at the end of the procmailrc, you can forward the (processed) message to your external e-mail address.

Related Question