Linux - SecurityThis forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I just wanted to ask if anyone here knows a way to log commands ran by users via ssh (ie: no bash shell).
I've got /etc/profile set up to use logger and logname to log whatever a user types in their bash shell to syslog-ng. This does not work to log what I and other sysadmins do in ssh loops (which I do often to do work on multiple servers). A very simple example of something we might do is:
for i in server1 server2 server3 ; do ssh user@$i "uname -a" ; done
I would like to log that 'user' ran 'uname -a'! I've experimented with a package called snoopy, which records all exec() calls made by users and it does indeed catch 'uname -a', but it spams the logs with a bunch of other system call info which I do not want. I've got syslog-ng and can set up whatever filters to catch stuff...i just need the commands to show up SOMEWHERE so that when something screws up we can audit and backtrack.
I was just wondering if anyone here has dealt with this problem before and if they had come up with anything?
Unfortunately, both of those monitor shell sessions. SSHd seems to be making exec() calls without invoking a proper shell. If i or any other admin wanted to, say, install snmpd on 15 boxes i'm not going to log into each one, im going to do for i in `cat serverlist` ; do ssh $i "sudo yum install snmpd -y" ; done.
It looks like I'm going to have to look at process accounting. Should probably do this anyways to keep track of config management daemons.
Anyways figured I'd ask. I've used psacct packages and they kind of suck. If anyone knows of something that could keep track of sshd feel free to post! Snoopy does it but it's kinda hokey, not sure how well it would stand up in a production environment.
There's other ways to log syscalls. In kernel 2.4 you had Syscalltrace and GRSecurity verbose logging. In kernel 2.6 GRSecurity should still be usable in terms of logging syscalls, else the Audit package should be able to. Whichever option you chose, it would need to be set up properly before use though the level of invasiveness depends on the distributions and kernels in use.
Maybe I don't understand you, but what's wrong with using sudo?
From the sudo manpage:
Quote:
sudo can log both successful and unsuccessful attempts (as well as
errors) to syslog(3), a log file, or both. By default sudo will log
via syslog(3) but this is changeable at configure time or via the sudo-
ers file.
Cool thanks for the info unSpawn. I will likely report back here once I finally get the chance to work on this. After a quick search, it looks like the latest 2.6.x series linux kernels have some pretty good accounting updates.
chrism01, sudo does indeed log even if you're calling a command from ssh without invoking a shell:
zigz$ ssh user@host1 "sudo this gets ran and logged on host1"
but nothing gets logged in this scenario:
zigz$ ssh user@host1 "this gets ran on host1 but does not get logged"
Sysadmins are not going to use sudo when they don't need to, and unprivileged users can't use sudo. Also if root ssh logins are enabled sudo is never needed.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.