LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
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 02-18-2013, 05:35 PM   #1
KinnowGrower
Member
 
Registered: May 2008
Location: Toronto
Distribution: Centos && Debian
Posts: 347

Rep: Reputation: 34
many users has root password and how to find who did what


Many users has root password on Debian Linux server. Some body has changed some permission on some directories. I need to find which user did this. Is there any way to find specifically who did this?.
 
Old 02-18-2013, 05:37 PM   #2
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,148
Blog Entries: 2

Rep: Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886
No, you can't since all users have logged in as the same user. You should consider to use a sudo setup with fine grained restrictions and logging possibilities instead.
May I ask why your users have to have the root password?
 
Old 02-18-2013, 05:47 PM   #3
KinnowGrower
Member
 
Registered: May 2008
Location: Toronto
Distribution: Centos && Debian
Posts: 347

Original Poster
Rep: Reputation: 34
I forget to mention one thing. Every user has their own account setup with ssh key based login. So every user login by thier own account and then they su to root.
Quote:
May I ask why your users have to have the root password?
It is kind of legacy thing. Even I don't know. I am new there and let's see how much it will take me to convince my seniors, that this is not the right way. . I am trying to setup the environment, so that developers/non-admin users can do their task without root access.
 
Old 02-18-2013, 05:56 PM   #4
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,148
Blog Entries: 2

Rep: Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886
It doesn't make a difference if the users first login as their own users and than su to root, at that point they are root and not differentiable.
Sometimes legacy setups can be quite inconvenient and even dangerous. Good luck with convincing your seniors to implement a clean and secure solution.
 
Old 02-19-2013, 02:32 AM   #5
sharadchhetri
Member
 
Registered: Aug 2008
Location: INDIA
Distribution: Redhat,Debian,Suse,Windows
Posts: 179

Rep: Reputation: 23
Quote:
Originally Posted by TobiSGD View Post
It doesn't make a difference if the users first login as their own users and than su to root, at that point they are root and not differentiable.
Sometimes legacy setups can be quite inconvenient and even dangerous. Good luck with convincing your seniors to implement a clean and secure solution.
yes it is possible by saving their logs.
In debian you have to do some settings.

* Allow users to do "sudo su - " only .So that they become root.
* I implemented this method and keeping track of users successfully . I have written same in my blog.Read the post and with debian system do some changes. I did this in CentOS/Red Hat. And the same logic you can use with Debian also.Here you have play with .bash_profile of users.

http://sharadchhetri.com/2011/12/02/...ndary-logging/
 
Old 02-19-2013, 05:19 AM   #6
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,148
Blog Entries: 2

Rep: Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886
Quote:
Originally Posted by sharadchhetri View Post
yes it is possible by saving their logs.
In debian you have to do some settings.

* Allow users to do "sudo su - " only .So that they become root.
* I implemented this method and keeping track of users successfully . I have written same in my blog.Read the post and with debian system do some changes. I did this in CentOS/Red Hat. And the same logic you can use with Debian also.Here you have play with .bash_profile of users.

http://sharadchhetri.com/2011/12/02/...ndary-logging/
It is not possible in the OP's case, without using sudo, but only su. I would also rather recommend to setup sudo in the way it is intended, giving the users only the rights they absolutely need for their job. This is common practice and known as Principle of least privilege.
 
1 members found this post helpful.
Old 02-19-2013, 06:33 AM   #7
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Quote:
Originally Posted by sharadchhetri View Post
yes it is possible by saving their logs.
Yes, but not the way you do it.


Quote:
Originally Posted by sharadchhetri View Post
I implemented this method and keeping track of users successfully
Only because you don't have (or don't audit for?) malicious users. Basically what you do amounts to:
Code:
mkdir -p /var/log/users_historylogs
cat >> /root/.bashrc <<EOF
export HISTSIZE=10000
export HISTTIMEFORMAT="%F %T "
export HISTFILE=/var/log/users_historylogs/root_history-$(who am i | awk ‘{print $1}’;exit)
export PROMPT_COMMAND=’history -a’
EOF
It uses the shells internal relative time stamping, uses 'whoami' incorrectly (will always return "root" when used there) but most importantly can all be reverted or fscked up once somebody is root.
 
Old 02-19-2013, 06:48 AM   #8
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Quote:
Originally Posted by KinnowGrower View Post
Many users has root password on Debian Linux server. Some body has changed some permission on some directories. I need to find which user did this. Is there any way to find specifically who did this?.
The problem (apart from your obvious problem that is) is Linux doesn't come with an all-encompassing audit trail out of the box. On a machine that doesn't use remote syslog in combination with the audit service and Rootsh or any other logging shell what remains is:
- user login records in /var/log/wtmp ('man last'),
- if you touched /var/log/btmp you also have bad logins there ('man lastb'),
- PAM user login records in /var/log/secure or equivalent,
- if BSD Process Accounting was enabled (psacct) the 'sa', 'lastcomm' and related commands,
- possibly login records in networked service daemon logs,
- users shell history, and
- file system MAC time stamps.

Correlation, creating a time line out of log file entries, login records, user shell history, 'lastcomm --user [someaccountname]' and file system MAC time stamps may to some extent reveal when and in what order the system was altered but it will always be an incomplete picture and you won't be able to assert whatever you (think you) see is free of tampering.

(When pondering a better audit trail see http://www.linuxquestions.org/questi...8/#post3997650 and http://www.linuxquestions.org/questi...patches-34823/.)
 
1 members found this post helpful.
Old 02-19-2013, 06:58 AM   #9
sharadchhetri
Member
 
Registered: Aug 2008
Location: INDIA
Distribution: Redhat,Debian,Suse,Windows
Posts: 179

Rep: Reputation: 23
Quote:
Originally Posted by unSpawn View Post
The problem (apart from your obvious problem that is) is Linux doesn't come with an all-encompassing audit trail out of the box. On a machine that doesn't use remote syslog in combination with the audit service and Rootsh or any other logging shell what remains is:
- user login records in /var/log/wtmp ('man last'),
- if you touched /var/log/btmp you also have bad logins there ('man lastb'),
- PAM user login records in /var/log/secure or equivalent,
- if BSD Process Accounting was enabled (psacct) the 'sa', 'lastcomm' and related commands,
- possibly login records in networked service daemon logs,
- users shell history, and
- file system MAC time stamps.

Correlation, creating a time line out of log file entries, login records, user shell history, 'lastcomm --user [someaccountname]' and file system MAC time stamps may to some extent reveal when and in what order the system was altered but it will always be an incomplete picture and you won't be able to assert whatever you (think you) see is free of tampering.

(When pondering a better audit trail see http://www.linuxquestions.org/questi...8/#post3997650 and http://www.linuxquestions.org/questi...patches-34823/.)

will always return "root" when used there
No ,it will save the log like like this.
in /var/log it will save with root_history-username-AndDateFormat
Kindly try in your system first. I tried in CentOS and it is in production environment.

I am not misleading anyone with this information. Some blogs has already shared this link. All the things which I have written in my blog are practically done.

First do the try and let me know.
 
Old 02-19-2013, 07:52 AM   #10
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Quote:
Originally Posted by sharadchhetri View Post
No ,it will save the log like like this.
in /var/log it will save with root_history-username-AndDateFormat
Yes, you're right, it does. But regardless of that logging this way isn't tamper-free as root can alter any variables and files and it only logs commands executed on the command line whereas Rootsh can log even what you type inside a CLI text editor. So this still can't or shouldn't be part of what I'd define as a proper audit trail.
 
Old 02-19-2013, 08:39 AM   #11
sharadchhetri
Member
 
Registered: Aug 2008
Location: INDIA
Distribution: Redhat,Debian,Suse,Windows
Posts: 179

Rep: Reputation: 23
Quote:
Originally Posted by unSpawn View Post
Yes, you're right, it does. But regardless of that logging this way isn't tamper-free as root can alter any variables and files and it only logs commands executed on the command line whereas Rootsh can log even what you type inside a CLI text editor. So this still can't or shouldn't be part of what I'd define as a proper audit trail.
Ok I got it, when a user become root he can do anything.But user will think before if he do anything mischievous.
(1)We can save the log in remote server as well.
(2)second thing we should use chattr command to immute the log dir as well as .bashrc.So that if anyone will try to remove immute on directory, we can capture his activity in local and remote log server also.
(3)here the last login in server log must also be remotely saved.
(4)We must have a single centralised server (bation host) only from which user can do login. In that server user only restricted to use ssh to other server.In this server also, we can use this logging system .
Through last 3 and 4 step we can track who was last person who tried to login in that server.
(5) Co. must have policy,user should not share their credential to anyone.If they do Co. should take proper action on him/her.

I hope by this way we can achieve almost main concern of Question that is user should not do any damage in server. So user will think before what he is doing.
 
Old 02-19-2013, 08:43 AM   #12
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,313

Rep: Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918
Code:
[schneidz@hyper ~]$ sudo tail -f /var/log/secure
Feb 19 09:40:43 hyper sudo: schneidz : TTY=pts/2 ; PWD=/home/schneidz ; USER=root ; COMMAND=/usr/bin/tail -f /var/log/secure
Feb 19 09:40:53 hyper sudo: schneidz : TTY=pts/1 ; PWD=/home/schneidz ; USER=root ; COMMAND=/bin/ls
Feb 19 09:41:17 hyper su: pam_unix(su-l:session): session opened for user root by schneidz(uid=500)
 
1 members found this post helpful.
Old 02-19-2013, 08:45 AM   #13
sharadchhetri
Member
 
Registered: Aug 2008
Location: INDIA
Distribution: Redhat,Debian,Suse,Windows
Posts: 179

Rep: Reputation: 23
and it is better to have something rather then nothing.
 
Old 02-19-2013, 08:48 AM   #14
sharadchhetri
Member
 
Registered: Aug 2008
Location: INDIA
Distribution: Redhat,Debian,Suse,Windows
Posts: 179

Rep: Reputation: 23
@schneidz , appreciate you also pointed out good thing .
 
Old 02-19-2013, 08:52 AM   #15
sharadchhetri
Member
 
Registered: Aug 2008
Location: INDIA
Distribution: Redhat,Debian,Suse,Windows
Posts: 179

Rep: Reputation: 23
Quote:
Originally Posted by sharadchhetri View Post
@schneidz , appreciate you also pointed out good thing .
I would like to share my personal experience when auditor asked why the recommended settings are not in place.The file was edited before 6 month
At that time I found the guy who did the changes. timestamp of files and directory also matters if they exist.If someone remove log is there

As unSpawn said about rootsh. That is also good thing. http://linux.die.net/man/1/rootsh .We can utilise both things together.

Last edited by sharadchhetri; 02-19-2013 at 08:57 AM.
 
  


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
[SOLVED] How can the non-root users change their password if....... challavijay Linux - Newbie 3 07-31-2010 02:55 PM
did not find any option for root password for root user in ubuntu 9.10 linux.ab Linux - Newbie 1 03-02-2010 02:58 AM
RHEL5 Users cannot change password, but root can ggiwtc Linux - Server 2 12-10-2008 02:56 PM
How to let several users log in to the internet - without root password frank320 Fedora 4 05-25-2007 09:34 AM
Is it safe to remove root (and other users') password? simopal6 Linux - Security 11 05-19-2007 02:43 PM

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

All times are GMT -5. The time now is 05:07 PM.

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