The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Special Forums > Security
.
google unix.com



Security Discuss UNIX and Linux computer and network security, cybersecurity, cyberattacks, IT security, CISSP, OWASP and more.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Displaying a dialog box using terminal commands keshav.murthy@r Shell Programming and Scripting 1 07-16-2008 11:36 AM
Can't login root account due to can't find root shell neikel AIX 2 01-30-2008 11:07 PM
How to allow root login from a specified terminal ? XP_2600 SUN Solaris 3 11-27-2006 04:01 AM
Terminal Commands indigoecho UNIX for Dummies Questions & Answers 5 12-16-2003 01:41 AM
won't allow root login from another terminal to my sun kymberm UNIX for Dummies Questions & Answers 3 07-03-2003 12:11 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 10-19-2008
vishnu787 vishnu787 is offline
Registered User
  
 

Join Date: Oct 2008
Posts: 2
Unhappy How do i find all the commands entered by root on any terminal

Can any one help me with a script, which runs in background and mails me all the commands entered by root on any terminal for every hour. We have multiple people having root access on the server and creating a mess,i just wanted to monitor all the activity of the root.
  #2 (permalink)  
Old 10-19-2008
Smiling Dragon's Avatar
Smiling Dragon Smiling Dragon is offline Forum Advisor  
Disorganised User
  
 

Join Date: Nov 2007
Location: New Zealand
Posts: 921
You won't be able to do it at the scripting level unfortunately unless you already have a mechanism in place to capture the commands and just want to automate the transfer of them.

In order to really get a handle on keeping watch over your admins with root access, you'll need to hook into something at a much lower level. Solaris has a set of tools called the BSM (Basic(?) Security Module I think) which will allow you to get right down to the individual system calls if you want. Other OS's will likely have similar options avialable to them too. Post your OS here and with a little luck someone will be able to identify what you'll need to look at to get this going.

Another option is to look at tools like tripwire and remote syslog servers - catch the end result of the commands rather than the commands themselves. Provided everything is logged realtime to a remote server that the users in question do not have access to, you can review what they've done. Just remember to have them sign something to promise they won't turn off the logging and immediatly terminate the employment of anyone that breaks this (you will see it disable even if you can't see what happens afterwards).

Yet another option (and my preference) is to cut back the access. Use sudo to grant specific sets of commands to specific groups of users. Use file permissions to grant read-only access to users that only need that. Use setuid menus to provide for the use of more complex programs while retaining logging of what is being done.

I am one of the two senior engineers responsible for over a hundred servers and I don't know the root password to any of my boxen. It's not actually that tough to set up a three-way model to keep your access control, audit, and admin work seperate. You can't prevent someone playing silly-buggers but you can certainly catch them
  #3 (permalink)  
Old 10-20-2008
vishnu787 vishnu787 is offline
Registered User
  
 

Join Date: Oct 2008
Posts: 2
The main problem is we have a application testing team and couple of guys have the root access and they think they are admins....unfortunately i am from the unix team who had to support the servers used by testing team. The funniest part is they don't want to use sudo, and i have to cleanup the mess created by them every time.

I thought it would be a great idea to capture the input from standard input,whenever anybody logs in as root.

Iam trying to convince them to loose direct root access and use sudo....but these buggers dont seem to agree with me.
  #4 (permalink)  
Old 10-20-2008
Reboot's Avatar
Reboot Reboot is offline
Registered User
  
 

Join Date: Sep 2008
Location: Asia Pecific.
Posts: 31
You can set the default login shell as Bash.
This shell is having the tool known as History.
Anyone logged with this shell if execute any command then that command will get stored and appended to /.bash_history file.
You can make a script which will mail you the contents of /.bash_history
at your will and you will have all commands executed by root with
you......

Hope this will help.....
  #5 (permalink)  
Old 10-20-2008
Smiling Dragon's Avatar
Smiling Dragon Smiling Dragon is offline Forum Advisor  
Disorganised User
  
 

Join Date: Nov 2007
Location: New Zealand
Posts: 921
Quote:
Originally Posted by Reboot View Post
You can set the default login shell as Bash.
This shell is having the tool known as History.
Anyone logged with this shell if execute any command then that command will get stored and appended to /.bash_history file.
You can make a script which will mail you the contents of /.bash_history
at your will and you will have all commands executed by root with
you......
Ah, but what happens if you have two people logged in as root at the same time? It would be a bit tough to distinguish one session from another...

I suppose you could use 'script "/some/log/dir`who am i | awk '{ print $1 }'`-`date`"' ...

As for moving the users over to another access model, set up the 'new way' and show the users. You can reassure them that they will retain their su rights to root for now to give them a chance to evaluate the new method. Watch the sulog file and contact the person each time they use su to ask what they tried to do via sudo but couldn't. You can then fix whatever it was (or remind them that the access will be taken away and they should be finidng all the issues before it's too late).
Once you have all the problems cleared up, change the password to something only you know.

If you meet resistance, talk to your risk team and show them the very big risk involved in having more than one person able to do work as root without being able to trace who did what. Risk guys hate being unable to trace things back to a single person.
  #6 (permalink)  
Old 10-21-2008
Reboot's Avatar
Reboot Reboot is offline
Registered User
  
 

Join Date: Sep 2008
Location: Asia Pecific.
Posts: 31
Hi.. Smiling Dragon You are right......
It would be a bit tough to distinguish one session from another when two people logged in as root at the same time....

So, for that I have a solution......
First make Sure that you have sufficient space in / then do following :

1. Make a directory /record.
2. Put following entries in /.bashrc file:
x=`tty | cut -c 6- |tr '[/]' '[.]'`
if [ ! -d /record ] ; then
mkdir -p /record
fi
if [ ! -f /record/$x ] ; then
touch /record/$x
fi
echo >> /record/$x
echo " *********************************** " >> /record/$x
echo >> /record/$x
script -a /record/$x

Now, when anyone will log in to the system each time you are going to get his commands recorded to /record/pts.# file along with time and date of login. Where "#" is the terminal number given by tty command.The commands will get appended to this file (not over written).

So, you will have to monitor these files in /record directory regularlly so as to limit their size and growth.
No doubt you will have to set default shell as Bash.

Hope this will help.....

Cheers.... ......

Last edited by Reboot; 10-21-2008 at 04:56 PM..
  #7 (permalink)  
Old 10-24-2008
vampirodolce's Avatar
vampirodolce vampirodolce is offline
Registered User
  
 

Join Date: Oct 2008
Location: Italy
Posts: 9
Hi Reboot,
for some reason when I use script (/usr/bin/script) in .bashrc, as soon as the user logs in the shell goes crazy (e.g. CPU 100%) and the output file - typescript in my case - becomes huge. Do you know why?
The command 'script' on a command line works just fine, it's the .bashrc that doesn't like it. I am using Debian Etch.
Sponsored Links
Closed Thread

Bookmarks

Tags
linux commands

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 07:00 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0