Solved

Monitor CentOS root activity through SSH

Posted on 2014-03-06
5
947 Views
Last Modified: 2014-03-14
Hello,

I have a contractor working on a server and using root access. Right now I have imperfect solution of using 'tail -f /root/.bash_history' > log.txt through ssh. I need to have a live streaming record of all system calls and terminal commands for the root activity on a remote server through ssh.

Thanks!
0
Comment
Question by:Sanction
5 Comments
 
LVL 28

Accepted Solution

by:
Jan Springer earned 500 total points
ID: 39910983
Require that he use "sudo" and update the sudoers file to allow him to run any command as sudo root without requiring a password.  Identify the log file in sudoers to log all commands and be sure to create an exclusion where he cannot read or write to this log file.
0
 
LVL 1

Expert Comment

by:Reza_a
ID: 39911051
You can enable audit, and then specify what sort of commands, system calls you need to log. There are some good commands for analysing those logs then.

But be aware that audit may generate huge log file depends on level that you are monitoring.
0
 
LVL 27

Expert Comment

by:skullnobrains
ID: 39912224
use the "ForceCommand" option in sshd_config to run a custom script that does what you expect or an existing tool such as rootsh.

if you redirect the output to an append-only file, or better a remote syslog, it will be quite difficult to bypass it without you noticing, even as root
0
 

Author Comment

by:Sanction
ID: 39914256
All good solutions! The only concern I have left is executing commands over ssh (ex. ssh user@server 'sudo bash -s' < local_script.sh) Any idea on how to restrict remote script execution and force the user to use shell to input all of the commands?
0
 
LVL 27

Expert Comment

by:skullnobrains
ID: 39928787
yes, use the "ForceCommand" option in ssh config file (see above)

also note that logging in sudo is absolutely trivial to bypass and is often bypassed accidentally by people who type "sudo sh" (which is roughly equivalent to "su") when they need to work as root so they just don't have to type sudo on evry line afterwards
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

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…
The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

831 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