Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

E-mail Alert on Root SSH Login

Discussion in 'E-mail Discussion' started by crazyaboutlinux, Jun 3, 2009.

  1. crazyaboutlinux

    crazyaboutlinux Well-Known Member

    Joined:
    Nov 3, 2007
    Messages:
    941
    Likes Received:
    0
    Trophy Points:
    66
    Want to be notified instantly when someone logs into my server as root
    With date time & local IP address
    Is it possible to do this thing?
     
    #1 crazyaboutlinux, Jun 3, 2009
    Last edited: Jun 3, 2009
  2. PlatinumServerM

    PlatinumServerM Well-Known Member
    PartnerNOC

    Joined:
    Jul 10, 2005
    Messages:
    400
    Likes Received:
    3
    Trophy Points:
    168
    Location:
    New Jersey, USA
    cPanel Access Level:
    Root Administrator
  3. ChrisRHS

    ChrisRHS Well-Known Member

    Joined:
    Jul 12, 2006
    Messages:
    292
    Likes Received:
    5
    Trophy Points:
    168
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  4. crazyaboutlinux

    crazyaboutlinux Well-Known Member

    Joined:
    Nov 3, 2007
    Messages:
    941
    Likes Received:
    0
    Trophy Points:
    66
    what can i do to this /root/.bashrc
     
  5. Infopro

    Infopro cPanel Sr. Product Evangelist
    Staff Member

    Joined:
    May 20, 2003
    Messages:
    16,161
    Likes Received:
    370
    Trophy Points:
    583
    Location:
    Pennsylvania
    cPanel Access Level:
    Root Administrator
    Twitter:
    LFD does this. You might want to take a look at your CSF configuration. This is covered there along with email alerts for many other things as well.

    No need to edit that file, IMHO..
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  6. crazyaboutlinux

    crazyaboutlinux Well-Known Member

    Joined:
    Nov 3, 2007
    Messages:
    941
    Likes Received:
    0
    Trophy Points:
    66
    what exact to look in CSF configuration
     
  7. crazyaboutlinux

    crazyaboutlinux Well-Known Member

    Joined:
    Nov 3, 2007
    Messages:
    941
    Likes Received:
    0
    Trophy Points:
    66
    after lot of googling i got below

    & its really doing great job

    Code:
    
    So lets get started!
    
    1. Login to your server and su to root, I know the irony!
    
    2. cd /root
    
    3. pico .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. Crtl + X  then Y
    
    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.
    
     
Loading...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice