Linux Configure sudo

Ticker

6/recent/ticker-posts

Linux Configure sudo

Question: We have some users on all app servers in Stratos Datacenter. Some of them have been assigned some new roles and responsibilities, therefore their users need to be upgraded with sudo access so that they can perform admin level tasks.

a. Provide sudo access to user jim on all app servers.

b. Make sure you have set up password-less sudo for the user.

Please Note:-  Perform the below commands based on your question server,  user name & other details that might differ. So please read the task carefully before executing it. All the Best 👍


Solution:  

1. Login on all app servers & switch to root user

thor@jump_host ~$ ssh tony@stapp01

The authenticity of host 'stapp03 (172.16.238.12)' can't be established.

ECDSA key fingerprint is SHA256:jQBzPUeKPaiyjrpKdy6e4PG/2IswOUaZYIogb7o1SHE.

ECDSA key fingerprint is MD5:1f:11:06:a6:ec:6c:f5:37:38:31:79:ad:a6:70:94:37.

Are you sure you want to continue connecting (yes/no)? yes

Warning: Permanently added 'stapp01,172.16.238.10' (ECDSA) to the list of known hosts.

tony@stapp01's password:

[tony@stapp01~]$ sudo su -

 We trust you have received the usual lecture from the local System

Administrator. It usually boils down to these three things:

     #1) Respect the privacy of others.

    #2) Think before you type.

    #3) With great power comes great responsibility.

 [sudo] password for tony:

[root@stapp01 ~]#


2. Check user is existing & have sudo permission 

[root@stapp01 ~]# id jim
uid=1002(jim) gid=1002(jim) groups=1002(jim)
[root@stapp01 ~]#
 
[root@stapp01 ~]# su - jim
[jim@stapp01 ~]$
 
[jim@stapp01 ~]$ sudo cat /etc/sudoers |grep jim
 We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:
  #1) Respect the privacy of others.
  #2) Think before you type.
  #3) With great power comes great responsibility.
  [sudo] password for jim:
 [jim@stapp01 ~]$


3. switch to root and provide sudo permission without a password 

[jim@stapp01 ~]$ logout
[root@stapp01 ~]#
[root@stapp01 ~]# visudo
[root@stapp01 ~]#
[root@stapp01 ~]# su - jim
Last login: Tue Jul 20 17:48:02 UTC 2021 on pts/0
[jim@stapp01 ~]$
[jim@stapp01 ~]$ sudo cat /etc/sudoers |grep jim
jim    ALL=(ALL)   NOPASSWD:ALL
[jim@stapp01 ~]$
[jim@stapp01 ~]$

Please Note:- I have shown only for stapp01
You have to do this in all app server stapp01,stapp02, stapp03. 

4.  Click on Finish & Confirm to complete the task successfully

Happy Learning!!!!


Apart from this if you need more clarity,  I have made a  tutorial video on this

please go through and share your comments. Like and share the knowledge



Post a Comment

0 Comments

Latest Posts

KodeKloud Kubernetes Security CKS  Lab Challenge 4 |  Audit-policy | Install & configure falco utility | Inspect the API server audit logs and identify the user