LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 10-21-2010, 09:16 AM   #1
devUnix
Member
 
Registered: Oct 2010
Posts: 606

Rep: Reputation: 59
Logging Activities when su command is issued


Hi,


I want to log the following information whenever a user executes "su - root"
  • The User Name who is executing the "su" command and
  • Date & Time (timestamp) when he/she does it

I have tried this:

In the file /etc/profile

I have entered this line:


Code:
echo $USER >> /tmp/logins.log
But, as we know, the file /etc/profile is executed when a user logs-in. So, the user name, which gets recorded, is that of the root itself instead of the user who is executing the "su" command.

Any ideas to achieve the desired result?

I put in other words: I want to track down whenever a user issues "su - root" so that I can know who performed a particular activity on the server.

The problem is that, let's say, we are 10 people in the support. We have our own log-in credentials. But to perform certain tasks we need to "su - root". But that makes it difficult for us to determine who did what.

In fact, we are not using the root account. We have a log-in account which has been assigned sufficient permissions for the activities. We do this "su - specialUser" and perform those activities. But as the case is, it is not practical to determine who did what as we all know specialUser's password.

Is the problem clear now? Please ask me if you need more details. One more point, we are not using "sudoers" or "sudo". Why? That is the policy of the client / customer that a special user account be created and be used for those special activities which normal users can't perform.
 
Old 10-21-2010, 09:34 AM   #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 distro/version? This may be already getting logged.
 
Old 10-21-2010, 01:08 PM   #3
devUnix
Member
 
Registered: Oct 2010
Posts: 606

Original Poster
Rep: Reputation: 59
Quote:
Originally Posted by anomie View Post
What distro/version? This may be already getting logged.
System-1:

Code:
bash-3.2$ uname -vrs
AIX 3 5
System-2:

Code:
[root@host-6-14 ~]$ uname -rs
Linux 2.6.18.1
 
Old 10-21-2010, 01:34 PM   #4
anomie
Senior Member
 
Registered: Nov 2004
Location: Texas
Distribution: RHEL, Scientific Linux, Debian, Fedora
Posts: 3,935
Blog Entries: 5

Rep: Reputation: Disabled
How about -
Code:
$ cat /etc/issue
- on the Linux system?

(I don't know AIX.)
 
Old 10-21-2010, 02:06 PM   #5
devUnix
Member
 
Registered: Oct 2010
Posts: 606

Original Poster
Rep: Reputation: 59
Quote:
Originally Posted by anomie View Post
How about -
Code:
$ cat /etc/issue
- on the Linux system?

(I don't know AIX.)
Code:
[root@host-6-14 ~]$ cat /etc/issue
Fedora Core release 2 (Tettnang)
Kernel \r on an \m

[root@host-6-14 ~]$


[root@host-6-14 ~]$ uname -r -m
2.6.18.1 i686
[root@host-6-14 ~]$
 
Old 10-21-2010, 02:22 PM   #6
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 27,721

Rep: Reputation: 8169Reputation: 8169Reputation: 8169Reputation: 8169Reputation: 8169Reputation: 8169Reputation: 8169Reputation: 8169Reputation: 8169Reputation: 8169Reputation: 8169
Quote:
Originally Posted by devUnix View Post
Hi,
I want to log the following information whenever a user executes "su - root"
  • The User Name who is executing the "su" command and
  • Date & Time (timestamp) when he/she does it

I have tried this:
In the file /etc/profile I have entered this line:
Code:
echo $USER >> /tmp/logins.log
But, as we know, the file /etc/profile is executed when a user logs-in. So, the user name, which gets recorded, is that of the root itself instead of the user who is executing the "su" command.

Any ideas to achieve the desired result?

I put in other words: I want to track down whenever a user issues "su - root" so that I can know who performed a particular activity on the server.

The problem is that, let's say, we are 10 people in the support. We have our own log-in credentials. But to perform certain tasks we need to "su - root". But that makes it difficult for us to determine who did what.

In fact, we are not using the root account. We have a log-in account which has been assigned sufficient permissions for the activities. We do this "su - specialUser" and perform those activities. But as the case is, it is not practical to determine who did what as we all know specialUser's password.

Is the problem clear now? Please ask me if you need more details. One more point, we are not using "sudoers" or "sudo". Why? That is the policy of the client / customer that a special user account be created and be used for those special activities which normal users can't perform.
The only thing that springs to my mind, is to move the actual "su" binary somewhere out of the normal path, and substitute your own "su" script file for it. That way, when the person executes an "su - specialuser", their logname/uid will be their OWN, and you can write it off to a log file. From there, you have their logname as a variable, and can pass it to the real 'su' command, where it will function normally.

May not work, but that's just a quick thought.
 
Old 10-21-2010, 05:35 PM   #7
anomie
Senior Member
 
Registered: Nov 2004
Location: Texas
Distribution: RHEL, Scientific Linux, Debian, Fedora
Posts: 3,935
Blog Entries: 5

Rep: Reputation: Disabled
Relatively current RH-family distros log su(1) activity to /var/log/secure. (Presumably it's using syslogd(8)'s authpriv facility.)

But Fedora Core 2?? No idea. If you can't figure it out, you may be stuck wrapping it as mentioned.
 
Old 10-27-2010, 10:13 AM   #8
urapain
LQ Newbie
 
Registered: Oct 2010
Location: Florida
Distribution: ubuntu redhat
Posts: 3

Rep: Reputation: 0
If you are rolling your own audit system, you should consider OSSEC (free). It is pretty easy to setup, and the default config covers a lot of territory. It monitors logon and su activity, as well as system modifications. Unless you have a really rock hard reason for sticking with FC2 I highly recommend Ubuntu.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Accidently issued command chmod 777 / san_to_all Linux - Newbie 28 09-30-2010 05:54 PM
Automatically append another piped command to issued command in bash amateen Programming 1 05-07-2009 06:36 AM
how to build a activities monitoring and logging system roamer_xk Programming 2 07-14-2005 05:49 PM
how to build a activities monitoring and logging system roamer_xk Linux - Security 1 07-14-2005 01:16 PM
Timestamp of previous command issued benjaminrtz Linux - General 1 04-16-2005 01:53 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 04:15 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