Thursday, May 14, 2020

How to use Sudo Policy Effectively

How to use Sudo Policy Effectively .


Security Feature  in LINUX , UNIX and Windows.

Windows OS:-

  • In older day's  window OS has lots loophole in security area like virus infection , not proper management of normal user and Privileges users.
  • Now-day new window OS uses User access control (UAC)  to protect the user , but still not quite but there is always chance of virus infection on windows server.


LINUX/ UNIX OS:-

  •   From the beginning its  hard to break security for Linux.
  •   Linux/UNIX always do good  job to manage the Privileges  administrative uses and Normal      user.
  •   Root is powerful account in Unix/Linux. If your take login as root then you are the God of   system    you can do anything , whatever you want to do. You feel like god of system. for eg. Wipe out entire    system, remove anything from the server.
  •  Login as Root  there always threat to system . You are the threat because you login as root user. or   you threat the entire  system security and  critical operation  by login as root user without proper   process.

  one of the unhealthy practice  is login as root to server , how ? if you have the root password you can login as root user  no issue , but if you use root  and doing there day to day activities then what happened? For  instance if you are  Team lead of Unix team and you handle more 1000 Linux server box and you   have the password for the root user and share within your team and team doing the day to day operation , team will happy because they are using root access and mistakenly someone from team executed some command and remove critical  file then  what happens?  or one more example someone from your  team left the organization and he has the password of every system then its another threat to security ? so you decided to change the password and again distributed within team
for day to day operation . So instead of doing this what if you just want users to have admin privileges only for certain task,instead of having full root privileges?


who is Savior , who can save us any clue guys ?

Sudo

I  guess someone called me , Don't worry i will come to rescue you,here we make some idea divided activities like admin privileges activities among normal regular user and admin user without login as root user. so plan is without login as root user we can still perform the admin task how lets explore sudo policy.

Well back soon withe Some Hands on Example.





When I use df -h as Oracle user i am getting df: `/root/.gvfs': Permission denied error.

Sometime on Linux Red Hat Enterprise Linux Server release 6.8 (Santiago) , when I  use df -h as Oracle user i am getting df: `/root/.gvfs': Permission denied error.

[oracle@oem ~]$ df -h
df: `/root/.gvfs': Permission denied
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda1        20G  7.5G   11G  42% /
tmpfs           3.8G  276K  3.8G   1% /dev/shm
/dev/sda3       1.9G   13M  1.8G   1% /tmp
/dev/sda5        31G   48M   29G   1% /u001
[oracle@oem ~]$ uname -a
Linux oem.expert.com 4.1.12-37.4.1.el6uek.x86_64 #2 SMP Tue May 17 07:23:38 PDT 2016 x86_64 x86_64 x86_64 GNU/Linux
[oracle@oem ~]$


after look/search about this issue i found some solution let me share what i did to resolve.

[oracle@oem ~]$ rpm -qa | egrep "fuse|gvfs"
gvfs-devel-1.4.3-26.el6.x86_64
gvfs-fuse-1.4.3-26.el6.x86_64
gvfs-archive-1.4.3-26.el6.x86_64
gvfs-1.4.3-26.el6.x86_64
gvfs-smb-1.4.3-26.el6.x86_64
fuse-2.9.4-1.0.1.el6.x86_64
gvfs-obexftp-1.4.3-26.el6.x86_64
gvfs-afc-1.4.3-26.el6.x86_64
fuse-libs-2.9.4-1.0.1.el6.x86_64
fuse-devel-2.9.4-1.0.1.el6.x86_64
gvfs-gphoto2-1.4.3-26.el6.x86_64
[oracle@oem ~]$


 Cause : gvfs is related to GNOME desktop  , As normal user its not mount and its gave the error 

df: `/root/.gvfs': Permission denied



Solution:-


  • Set GVFS_DISABLE_FUSE=1  value.
  • Disable GVF damon.

Login as Root user.

[oracle@oem ~]$ su - root
Password:
[root@oem ~]#
[root@oem ~]#
[root@oem ~]# vi /etc/X11/xinit/xinitrc.d/00-gvfs-disable-fuse.sh

[root@oem ~]# cat /etc/X11/xinit/xinitrc.d/00-gvfs-disable-fuse.sh
GVFS_DISABLE_FUSE=1
export GVFS_DISABLE_FUSE
[root@oem ~]#

After please reboot the Linux server and check with df -h  as oracle user you will not get that error.

[oracle@oem ~]$ whoami
oracle
[oracle@oem ~]$ df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda1        20G  7.5G   11G  42% /
tmpfs           3.8G   72K  3.8G   1% /dev/shm
/dev/sda3       1.9G   13M  1.8G   1% /tmp
/dev/sda5        31G   48M   29G   1% /u001
[oracle@oem ~]$