Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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.

share|improve this question
    
See unix.stackexchange.com/questions/19046/… for a similar question –  Olivier Berger Apr 11 '12 at 11:41

2 Answers 2

up vote 5 down vote accepted
+50

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.

share|improve this answer
2  
Procmail: see blog.fealdia.org/2008/06/14/encrypted-system-logs-to-gmail –  pjc50 Feb 16 '11 at 13:02

The catch-all way to do this is to edit the /etc/aliases file:

root:   me@someplace.else.com,someone.else@different.place.com

Run newaliases and you should be good to go.

Note you probably have to doctor your MTA (sendmail, or whatever) so that the messages emitted don't get deleted as spam, but that's a larger issue.

share|improve this answer
4  
And what about the encrypt and sign part of the question? –  maxschlepzig Feb 9 '11 at 10:45

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.