Solved

passwordless ssh monitoring

Posted on 2013-06-22
6
573 Views
Last Modified: 2013-06-24
Hi All,

I enabled passwordless ssh on some of the generic user accounts on some redhat linux 5 servers so anyone have his ssh key listed on that generic account's authorized_key will be allowed to ssh to the box without entering the password for that generic account.

I would like to know anything i can do to monitor who is actually using the generic account to login? i tried to add a environment variable to the user's ssh key that mark the username but i am not quite sure how i can use this variable to log the access.

thanks.
0
Comment
Question by:nokyplease
6 Comments
 
LVL 28

Expert Comment

by:Jan Springer
ID: 39268406
Have you tried modifying sshd_config to log in Verbose mode and optionally, logging to a separate file?
0
 
LVL 68

Assisted Solution

by:woolmilkporc
woolmilkporc earned 500 total points
ID: 39268573
I assume that you added something like

environment="OUSER=originating_user"

to the public key in ~/.ssh/authorized_keys on the target machine corresponding to the private key of originating_user on the source machine?

OK, this is indeed the only way to get the ID of the originating user on the target system I'm aware of.

Since the variable is exported to the user's environmnet you can only evaluate it from there.

Best add a logging command to a system-wide shell initialization file, like /etc/profile.

To log to a flat file e.g.:

[ ! -z $OUSER ] && echo "$(date) Remote user $OUSER logged in as local user $USER from $SSH_CLIENT" >> /var/log/ssh_access.log

Please be aware that, if your users can log in as root, this logfile is subject to manipulation by those users.

Logging to a remote syslog server is safer. (Well, /etc/profile is not really protected from being changed by root, but anyway  ....)

Set up a remote syslog connection for e.g. auth.info, then add something like this to /etc/profile:

[ ! -z $OUSER ] && logger -t ssh_access -p auth.info "Remote user $OUSER logged in as local user $USER from $SSH_CLIENT"
0
 
LVL 76

Expert Comment

by:arnold
ID: 39268692
Your /var/log/secure and /var/log/messages will include the IP from which the user is connecting

last username

You gave people keys to your house and then you are asking us to help you identify which individuals are using the keys you provided.
0
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 

Author Comment

by:nokyplease
ID: 39269282
Hi,

i added the logging command to the /etc/profile and it only can log user access for those user using bash shell? i have users using csh and nothing is being logged. Also i seems need to give write permission to the generic user account on the logging file otherwise i got permission denied when login.

thanks.
0
 
LVL 68

Accepted Solution

by:
woolmilkporc earned 500 total points
ID: 39269334
Yes, the generic users need write permission, because the log entry is created from the login shells of those users.

One more reason to consider using  syslog (even remote syslog to inhibit local root access)..

For csh/tcsh users you will have to add the logging command to /etc/csh.login or /etc/csh.cshrc.

Besides that, the syntax must be slightly different.

File:

if $?OUSER then
   echo "`date` Remote user $OUSER logged in as local user $USER from $SSH_CLIENT" >> /var/log/ssh_access.log
endif

Syslog:

if $?OUSER then
   logger -t ssh_access -p auth.info "Remote user $OUSER logged in as local user $USER from $SSH_CLIENT"
endif
0
 

Author Closing Comment

by:nokyplease
ID: 39273554
thanks
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

This document is written for Red Hat Enterprise Linux AS release 4 and ORACLE 10g.  Earlier releases can be installed using this document as well however there are some additional steps for packages to be installed see Metalink. Disclaimer: I hav…
Little introduction about CP: CP is a command on linux that use to copy files and folder from one location to another location. Example usage of CP as follow: cp /myfoder /pathto/destination/folder/ cp abc.tar.gz /pathto/destination/folder/ab…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
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…

743 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