Solved

How to identify SSH user interactive login?

Posted on 2016-08-03
15
72 Views
Last Modified: 2016-08-12
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

0
Comment
Question by:Julio Jose
  • 6
  • 4
  • 3
  • +1
15 Comments
 
LVL 37

Expert Comment

by:Gerwin Jansen
ID: 41741047
Did you try the who command? Does it show what you're after?
0
 
LVL 3

Expert Comment

by:Steven Roman
ID: 41741362
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
 

Author Comment

by:Julio Jose
ID: 41741558
I need to identify this user session from the log but not run any other command
0
 
LVL 3

Expert Comment

by:Steven Roman
ID: 41741561
Hello

Try to view the log below

tail /var/log/secure

Or you can try
tail /var/log/secure | grep root
0
 

Author Comment

by:Julio Jose
ID: 41741817
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
 
LVL 37

Expert Comment

by:Gerwin Jansen
ID: 41741906
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
 

Author Comment

by:Julio Jose
ID: 41741908
interest on RHEL 4,5,6, Solaris and AIX
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 37

Expert Comment

by:Gerwin Jansen
ID: 41741945
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
 

Author Comment

by:Julio Jose
ID: 41742488
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
 
LVL 37

Expert Comment

by:Gerwin Jansen
ID: 41742610
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
 

Author Comment

by:Julio Jose
ID: 41742651
apologize, I want to check exiting log for real user login with password using SSH client software
0
 
LVL 3

Expert Comment

by:Steven Roman
ID: 41742856
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
 
LVL 20

Expert Comment

by:tfewster
ID: 41743451
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
 

Author Comment

by:Julio Jose
ID: 41746843
So we should check WTMP to identify the user SSH interactive session?
0
 
LVL 20

Accepted Solution

by:
tfewster earned 500 total points
ID: 41747971
Yes, if you're only interested in interactive sessions, `last` will show you the contents of wtmp.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Setting up Secure Ubuntu server on VMware 1.      Insert the Ubuntu Server distribution CD or attach the ISO of the CD which is in the “Datastore”. Note that it is important to install the x64 edition on servers, not the X86 editions. 2.      Power on th…
I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension (http://www.experts-exchange.com/discussions/210281/Attachments-with-no-extension.html). This reminded me of questions tha…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:

707 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now