Solved

Monitor CentOS root activity through SSH

Posted on 2014-03-06
5
821 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 26

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 26

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

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

In my business, I use the LTS (Long Term Support) versions of Linux. My workstations do real work, and so I rarely have the patience to deal with silly problems caused by an upgraded kernel that had experimental software on it to begin with from a r…
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…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now