Solved

How to identify SSH user interactive login?

Posted on 2016-08-03
15
75 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
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 
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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Network Interface Card (NIC) bonding, also known as link aggregation, NIC teaming and trunking, is an important concept to understand and implement in any environment where high availability is of concern. Using this feature, a server administrator …
Using 'screen' for session sharing, The Simple Edition Step 1: user starts session with command: screen Step 2: other user (logged in with same user account) connects with command: screen -x Done. Both users are connected to the same CLI sessio…
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.:
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

896 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

14 Experts available now in Live!

Get 1:1 Help Now