How to identify SSH user interactive login?

Hi, on windows we can check the event log for login event that is login type 3 RDP interactive login session.

On Linux and Unix OS, I need to detect SSH user interactive login where the user login from laptop / pc but not the ssh session initial by the script, the common is wtmp log,  is that a way to identify?

root     pts/1        1.1.1.1       Thu Aug  4 09:35 - 14:45  (05:09)

Open in new window

Julio JoseAsked:
Who is Participating?
 
tfewsterConnect With a Mentor Commented:
Yes, if you're only interested in interactive sessions, `last` will show you the contents of wtmp.
0
 
Gerwin Jansen, EE MVETopic Advisor Commented:
Did you try the who command? Does it show what you're after?
0
 
Steven RomanCommented:
Hello

You can also run the following
w
who
wall (then ask them what they are ing and who they are)

Always create users and make them perform sudo or su for root access.

Hope this helps

Thanks
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
Julio JoseAuthor Commented:
I need to identify this user session from the log but not run any other command
0
 
Steven RomanCommented:
Hello

Try to view the log below

tail /var/log/secure

Or you can try
tail /var/log/secure | grep root
0
 
Julio JoseAuthor Commented:
I can check the secure log for the root user but how do I know if root user are login via the script or application, I only need to capture if user login from the laptop / pc ssh client interactive login.
0
 
Gerwin Jansen, EE MVETopic Advisor Commented:
Which exact Linux version is this about? On Ubuntu for example, you have to look at /var/log/auth.log - lines with sshd in it.
0
 
Julio JoseAuthor Commented:
interest on RHEL 4,5,6, Solaris and AIX
0
 
Gerwin Jansen, EE MVETopic Advisor Commented:
It is /var/log/secure on Red Hat - about the others: AIX should be in syslog, Solaris as well (but has to be configured in syslog.conf).
0
 
Julio JoseAuthor Commented:
I tried SFTP and SSH both having same log in the "secure" I need to identify which one actually user login from the SSH client software
0
 
Gerwin Jansen, EE MVETopic Advisor Commented:
You are very unclear, first you talk about a script, now sftp. Both ssh and sftp use the same port (ssh). I do not understand what you want.
0
 
Julio JoseAuthor Commented:
apologize, I want to check exiting log for real user login with password using SSH client software
0
 
Steven RomanCommented:
Hello,


I think with the answers posted that should get you what you need.

Or are you wanting to be alerted by some way when someone does login to the Server?
If so you are looking for a script or crontab job.  This will get more complex but can be done.

I have a script when ever someone logs in as root or su's in to send me an email
0
 
tfewsterCommented:
If someone starts an interactive session via ssh (or, $DEITY forbid, telnet), whether using the password or an ssh key,  it's logged in wtmp (on AIX, HP-UX and Linux and I believe Solaris as well), and the `last` command will show that session.

If some runs `ssh root@yourserver "command"`, it's logged in syslog but not wtmp. That's still a security issue  - Someone has direct root login and is using it, but it's harder to detect.

Setting PermitRootLogin = no in sshd_config solves the problem
0
 
Julio JoseAuthor Commented:
So we should check WTMP to identify the user SSH interactive session?
0
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.

All Courses

From novice to tech pro — start learning today.