How to set up an email reminder for SSH login on Linux

  
 

Enabling the SSH service on the Virtual Private Server (VPS) exposes the server to the Internet, providing an opportunity for hacking, especially when the VPS also allows direct access by root. The VPS should configure an automatic email alert for each successful SSH login attempt. The owner of the VPS server gets notifications of various SSH server access logs, such as logged in, login time, and source IP address. This is an important security concern for server owners to protect their servers from unknown login attempts. This is because if a hacker uses brute force to log in to your VPS via SSH, the consequences are serious.

In this article, I will explain how to set up an email warning for all SSH user logins on CentOS 6, CentOS 7, RHEL 6, and RHEL 7.

1, log in to your server as root;

2, configure warnings (/etc/bashrc) in the global source definition, this will take effect for both root and normal users. :
BASIC[root@vps ~]# vi /etc/bashrc

Add the following to the end of the above file.

echo ‘ALERT – Root Shell Access (vps.chendexin.com) on:’ `date` `who`

Copyright © Windows knowledge All Rights Reserved