Hi Guys,
I have an issue and it is driving me mad
I have been going through some of the security guides and I am trying to get the send email on root login to work.
I have added this piece of code to 2 accounts:-
The first account is root and I added the code to /root/.bashrc
The 2nd is added to /home/stephen/.bashrc
Now if I ssh in with my stephen account the email gets sent to my offsite gmail account okay, but if I login as root or su - from my stephen account,
the email that is sent by the code in /root/.bashrc gets sent to root with this error "Mail delivery failed: returning message to sender"
Within this message is this:-
Now my question is this. Why can the route be found when the code is run by the stephen account but not by the root account?
Note:- I have removed my real gmail email address and replaced with [email protected] as an illustration.
Many thanks for any help.
Regards
Stephen
I have an issue and it is driving me mad

I have been going through some of the security guides and I am trying to get the send email on root login to work.
I have added this piece of code to 2 accounts:-
Code:
echo 'ALERT - Root Shell Access (mydomain.com) on:' `date` `who` | mail -s "Alert: Root Access from `who | cut -d"(" -f2 | cut -d")" -f1`" [email][email protected][/email]
The first account is root and I added the code to /root/.bashrc
The 2nd is added to /home/stephen/.bashrc
Now if I ssh in with my stephen account the email gets sent to my offsite gmail account okay, but if I login as root or su - from my stephen account,
the email that is sent by the code in /root/.bashrc gets sent to root with this error "Mail delivery failed: returning message to sender"
Within this message is this:-
This message was created automatically by mail delivery software.
A message that you sent could not be delivered to one or more of its
recipients. This is a permanent error. The following address(es) failed:
[email protected]
Unrouteable address
Now my question is this. Why can the route be found when the code is run by the stephen account but not by the root account?
Note:- I have removed my real gmail email address and replaced with [email protected] as an illustration.
Many thanks for any help.
Regards
Stephen