Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a CentOS 6.2 server.

Whenever some one logs into the server using the terminal (SSH) the user profile (.bash_profile) is loaded.

Now my question is, is there a profile that loads whenever you use SFTP to login into the server via "FTP browsing software" ( I use WinSCP ), I want to send an email whenever a user logs into the server via SFTP. I already have the code to do this when a user logs into the terminal (SSH) when his profile loads.


share|improve this question
up vote 4 down vote accepted

This is the wrong way to go about getting login notifications, as users can change their profile or defeat this in a myriad of ways.

Instead, write a little script that watches your auth log and sends email when someone authenticates successfully.

share|improve this answer
I agree that this method would be the best but with my level of linux knowledge this would be a very tough challenge. I will only have 1 user (root), we are setting up a rule that this server can only be accessed by a few people only and whenever they do use that user to access the server we want to get an email. This is only to track unscheduled in user login into the server, this server can only be accessed internally. – Alex Oct 12 '12 at 9:20
Do it the right way the first time. It's just not worth taking shortcuts. Perhaps look into fail2ban. That could possibly be conscripted to send these emails. – EEAA Oct 12 '12 at 9:23

Your Answer


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.