Pages

SSH login alert via email




SSH login alert via email


So lets get started!

1. Login to your server and su to root,

2. cd  /root

3. vi .bashrc

4. Scroll to the end of the file then add the following:
echo 'ALERT - Root Shell Access (YourserverName) on:' `date` `who` | mail -s "Alert: Root Access from `who | cut -d'(' -f2 | cut -d')' -f1`" you@yourdomain.com

Replace YourServerName with the handle for your actual server
Replace you@yourdomain.com with your actual email address

5. Save and Exit the File


6. Give Excute Permission (Check file permission section  Click Here )

Now logout of SSH, close the connection and log back in! You should receive an email address of the root login alert a few minutes afterwards.

17 comments:

  1. when done perform these steps i got the following error,

    /usr/sbin/sendmail: No such file or directory
    "/root/dead.letter" 9/362
    . . . message not sent.

    Please help to sort this out.

    ReplyDelete
  2. when i perform these steps i got the following error,

    /usr/sbin/sendmail: No such file or directory
    "/root/dead.letter" 9/362
    . . . message not sent.

    Please help to sort this out.

    ReplyDelete
  3. you need to configure mailing on the server else how will server send the mail
    postfix or sendmail should be configured and runing for the above script...

    i hope you got it....

    ReplyDelete
  4. This article gives the light in which we can observe the reality. This is very nice one and gives indepth information. Thanks for this nice article.
    www.armadilloglass.co.uk |

    ReplyDelete
  5. This is an excellent post I seen thanks to share it. It is really what I wanted to see hope in future you will continue for sharing such a excellent post.
    www.zabusinessfromhome.com |

    ReplyDelete
  6. I surprised with the analysis you made to make this particular publish incredible. Wonderful activity! 
    travelodgeauburn |

    ReplyDelete
  7. It is very helpful for all the people on the web.I wanted to say that it's nice to know that someone else also mentioned this as I had trouble finding the same info elsewhere.
    southshoregreenhomes.com |

    ReplyDelete
  8. This article gives the light in which we can observe the reality. This is very nice one and gives indepth information. Thanks for this nice article.
    automazione-net.com |

    ReplyDelete
  9. This was the first place that told me the answer. I have added you to my bookmark list to check out new articles you post
    auto-satisfait |

    ReplyDelete
  10. Τhere is definately a great deal to learn ɑbout this issue. Ι love all of the points you've madе.
    exbulk |

    ReplyDelete
  11. Great article Lot's of information to Read...Great Man Keep Posting and update to People..Thanks 
    stepalaska |

    ReplyDelete
  12. I recently came across your blog and have been reading along. I thought I would leave my first comment. I don't know what to say except that I have enjoyed reading. Nice blog. I will keep visiting this blog very often.
    bluebusinessdialog |

    ReplyDelete
  13. The world is changing fast. people are also being changed.day by day we are becoming more dependant on degital system.yoU make me think of this really.You have a nice way of sharing your thoughts
    tgdffoodcongress2013 |

    ReplyDelete
  14.  It is very helpful for all the people on the web.I wanted to say that it's nice to know that someone else also mentioned this as I had trouble finding the same info elsewhere.
    Chew Food Tour |

    ReplyDelete
  15. شركة نقل عفش من الرياض الى جدة شركة نقل عفش من الرياض الى جدة
    شركة نقل عفش بحفر الباطن شركة نقل عفش بحفر الباطن
    شركة نقل عفش الجبيل شركة نقل عفش الجبيل
    شركة نقل عفش بالخبر شركة نقل عفش بالخبر
    شركة نقل عفش من الرياض الى البحرين شركة نقل عفش من الرياض الى البحرين

    شركة نقل عفش من الرياض الى سلطنة عمان شركة نقل عفش من الرياض الى سلطنة عمان

    ReplyDelete

Note:- Comment as: Option available to post without login select "Anonymous" from the drop down...........