Solved

passwordless ssh monitoring

Posted on 2013-06-22
6
581 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 29

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 78

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
Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

 

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

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.

Question has a verified solution.

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

If you use Debian 6 Squeeze and you are tired of looking at the childish graphical GDM login screen that is used by default, here's an easy way to change it. If you've already tried to change it you've probably discovered that none of the old met…
This article will explain how to establish a SSH connection to Ubuntu through the firewall and using a different port other then 22. I have set up a Ubuntu virtual machine in Virtualbox and I am running a Windows 7 workstation. From the Ubuntu vi…
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…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

759 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