passwordless ssh monitoring

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.
nokypleaseAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jan SpringerCommented:
Have you tried modifying sshd_config to log in Verbose mode and optionally, logging to a separate file?
0
woolmilkporcCommented:
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
arnoldCommented:
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
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

nokypleaseAuthor Commented:
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
woolmilkporcCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
nokypleaseAuthor Commented:
thanks
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Linux

From novice to tech pro — start learning today.