LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 05-12-2011, 01:50 PM   #1
Maragato
LQ Newbie
 
Registered: May 2011
Posts: 4

Rep: Reputation: 0
Doubt concerning keeping record of all commands executed with sudo or as root:


Hello folks, I have a doubt concerning how to keep log of all action executed by users in their tty`s. In order to achieve this I would start adding "history -a" to the PROMPT_COMMAND directive.
Then I would set the .bash_history permissions to append only with:
"chattr +a .bash_history"

On the following I could add
Code:
        if [ "$BASH" ]; then
	PROMPT_COMMAND="history -a;$PROMPT_COMMAND";
	readonly PROMPT_COMMAND
	readonly HISTSIZE
	readonly HISTFILE
	readonly HOME
	readonly HISTIGNORE
	readonly HISTCONTROL
	fi
to /etc/profile.

And finally deny users from executing shells in higher profiles:
Code:
Cmnd_Alias   NSU = /bin/su
testing ALL= ALL, !NSHELLS, !NSU
in /etc/sudoers

My question is are any caveats on my approach? I`ve created the user accounts with the newusers command and in result as they have not logged so far they don`t have a .bash_history in their homes is this a problem? Can I create this files or it would bring me problems regarding the order of its contents or something like that??


Regards.
 
Old 05-13-2011, 04:58 PM   #2
anomie
Senior Member
 
Registered: Nov 2004
Location: Texas
Distribution: RHEL, Scientific Linux, Debian, Fedora
Posts: 3,935
Blog Entries: 5

Rep: Reputation: Disabled
What OS / version?

Commands that are executed using sudo(8) should already be logged. Whipping together a contrived approach with the bash(1) history command is going to present difficulties. root can simply remove the immutable attribute.

Finally, using a blacklisting approach in sudoers(5) is a bad idea. It is more effective to whitelist the actions you want sudoers to be able to perform, and by default deny all the rest. (Why? Because too many utilities offer capabilities to drop to a shell or use other methods to escalate privileges in ways you might not expect.)
 
1 members found this post helpful.
Old 05-14-2011, 09:06 AM   #3
Maragato
LQ Newbie
 
Registered: May 2011
Posts: 4

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by anomie View Post
What OS / version?

Commands that are executed using sudo(8) should already be logged. Whipping together a contrived approach with the bash(1) history command is going to present difficulties. root can simply remove the immutable attribute.

Finally, using a blacklisting approach in sudoers(5) is a bad idea. It is more effective to whitelist the actions you want sudoers to be able to perform, and by default deny all the rest. (Why? Because too many utilities offer capabilities to drop to a shell or use other methods to escalate privileges in ways you might not expect.)
We aretunning Debian Linux but I'm not so affraid people would intentionally remove the files. But it is more like as those are production servers if they are modified and like 3 years later I need to check why and what has been done by whom I could go back to bash_histories and take a look.
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: How to properly redirect the output of command executed with sudo. LXer Syndicated Linux News 0 02-27-2011 11:50 PM
[SOLVED] Sudo does not allow access to root commands psionl0 Slackware 12 02-22-2011 03:42 PM
[SOLVED] how to log all the commands executed by root me_spearhead Linux - Security 5 08-13-2010 04:19 AM
Sudo Doubt? your_shadow03 Linux - Newbie 4 05-13-2009 01:36 PM
ssh record executed commands??? joangopan Linux - Newbie 4 05-13-2009 10:05 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 07:29 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration