?
Solved

How to include UNIX username and login IP address in php email script?

Posted on 2007-07-30
6
Medium Priority
?
356 Views
Last Modified: 2013-12-20
Hi,

I've created a php script to send email anytime a user logs into my linux server, I'm running SUSE 10.2 OS

I need a way to include in this email the user logging in and the IP address would be great as well.

I thought maybe adding parameters every time the script is called, something like sendmail.php $USER $IP
but i'm not sure if this is the right approach or how to implement it.

TIA
0
Comment
Question by:eDias
  • 2
  • 2
  • 2
6 Comments
 
LVL 10

Expert Comment

by:sakuya_su
ID: 19597715
how are they loged in? through a web interface? ssh?
0
 

Author Comment

by:eDias
ID: 19597733
these users are logging in via a SSH terminal!
0
 
LVL 16

Expert Comment

by:Kiran Paul VJ
ID: 19597736

$ip=$_SERVER['REMOTE_ADDR'];

"sendmail.php?userip=".$ip;

if only registerd users can access your website, u can get the username from the database, otherwise its impossible.

kiranvj
0
2017 Webroot Threat Report

MSPs: Get the facts you need to protect your clients.
The 2017 Webroot Threat Report provides a uniquely insightful global view into the analysis and discoveries made by the Webroot® Threat Intelligence Platform to provide insights on key trends and risks as seen by our users.

 
LVL 16

Expert Comment

by:Kiran Paul VJ
ID: 19597739
sorry i thought users are logging from website.
0
 
LVL 10

Accepted Solution

by:
sakuya_su earned 1000 total points
ID: 19597802
a way of alerting on SSH, is to use the bashrc, add the line:

echo 'ALERT Shell Access (YourserverName) on:' `date` `who` | mail -s "Alert: Root Access from `who | cut -d"(" -f2 | cut -d")" -f1`" you@yourdomain.com

be sure to change the email and servername
0
 

Author Comment

by:eDias
ID: 19597882
sakuya_su,

Thanks, for your fast reply and great answer... I added your input to a .sh file and included this in /etc/profile from now on when ever any one logs into my system I'll get notified
0

Featured Post

Threat Trends for MSPs to Watch

See the findings.
Despite its humble beginnings, phishing has come a long way since those first crudely constructed emails. Today, phishing sites can appear and disappear in the length of a coffee break, and it takes more than a little know-how to keep your clients secure.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn different types of Android Layout and some basics of an Android App.
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses
Course of the Month14 days, 2 hours left to enroll

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question