Get information on user login for linux

Posted on 2007-03-31
Medium Priority
Last Modified: 2010-05-18
I want to check on log-in information, I follow some doc and add the following to the end of

time=`date +%Y%m%d:%H%M%S`
echo "[$time]: $REMOTEHOST : $USER ." > /tmp/userlogin.log
mail -s "User Login !!" EMAILADDRESS < /tmp/userlogin.log
rm /tmp/userlogin.log

When I received the email, Subject reads OK.
However the body of the email contain only date time and user, the IP address it come from
is missing.  

Can anybody lighten me on this ?
Question by:ChanYiuPong
  • 2
LVL 27

Accepted Solution

Nopius earned 2000 total points
ID: 18831509
If users connect with 'ssh' then use $SSH_CLIENT instead of $REMOTEHOST.
BTW such kind of notification may be bypassed by clever users...

Author Comment

ID: 18831541
I think you get the 500 points, just one more question on SSH_CLIENT:
I saw a five digit between IP and port, what is that no ?
LVL 27

Expert Comment

ID: 18833669 51133 22 - client's IP
51133 - client's port number
22 - server's port number

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Hello EE, Today we will learn how to send all your network traffic through Tor which is useful to get around censorship and being tracked all together to a certain degree. This article assumes you will be using Linux, have a minimal knowledge of …
BIND is the most widely used Name Server. A Name Server is the one that translates a site name to it's IP address. There is a new bug in BIND (https://kb.isc.org/article/AA-01272), affecting all versions of BIND 9 from BIND 9.1.0 (inclusive) thro…
How to fix display issue, screen flickering issue when I plug in power cord to the machine. Before I start explaining the solution lets check out once the issue how it looks like after I connect the power cord. most of you also have faced this…
If you are looking for an automated solution for backup single or multiple Office 365 user mailboxes to Outlook data file, then you can use Kernel Office 365 Backup & Restore tool. Go through the video to check out the steps to backup single or mult…

587 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