Filters
Zo zoek je
  • Gewone woorden vinden namen, teksten en voorbeelden.
  • "twee woorden" vindt precies die zin.
  • --naam of -x vindt een optie.
  • #woord zoekt alleen in commando's.
  • @grep vindt lessen en labs die grep gebruiken.
  • Filters: cat:network · in:labs · in:notes · level:rhcsa · ch:8 · root:yes. Zet ! voor een woord om het weg te laten. OR tussen woorden betekent één ervan.
  • ↑ ↓ bewegen · Enter openen · Esc sluiten · / zoeken

Lab 6.2RHCSA 10, Hoofdstuk 6

Give limited admin rights with sudo

Niveau
Gemiddeld
30 min
Machines
server1
Status
Nog niet begonnen

Dit deel is nog niet vertaald. Je ziet de Engelse tekst.

Doel

Give one user full admin rights and give a team only the commands it needs. Test both, and make sure the sudo files have no errors.

Voordat je begint

  • Work on server1 as root (sudo -i).
  • The web server does not need to be installed: sudo checks the rule before the command runs.

Taken

  1. Create the user devops1 with full admin rights through sudo.
  2. Create the group webadmins and the user web1 as a member of it.
  3. Members of webadmins may run only these commands as root: systemctl restart httpd, systemctl status httpd and journalctl -u httpd. Put the rule in its own file.
  4. Create the user backup1. It may run /usr/bin/rsync as root without a password.
  5. Test as web1: list the allowed commands, run one allowed command and try cat /etc/shadow with sudo (this must fail).
  6. Check that all sudo files have a correct syntax.

Controleer je werk

sudo -l -U web1
sudo -l -U backup1
su - web1 -c 'sudo -n cat /etc/shadow'
visudo -c
  • sudo -l -U web1 lists only the three web commands.
  • backup1 shows NOPASSWD: /usr/bin/rsync.
  • The test with /etc/shadow fails ("not allowed" or "a password is required").
  • visudo -c says every file is "parsed OK".

Hints

Toon de hints
  • Full rights on RHEL: membership of the group wheel.
  • Use visudo -f /etc/sudoers.d/NAME. A group in a rule starts with %.
  • Use full paths in the rules: /usr/bin/systemctl, /usr/bin/journalctl.
  • NOPASSWD: goes right before the command list.

Oplossing

Toon de oplossing
  1. devops1 in wheel.
    useradd -G wheel devops1
    passwd devops1
  2. Group and user.
    groupadd webadmins
    useradd -G webadmins web1
    passwd web1
  3. A rule file for the group.
    visudo -f /etc/sudoers.d/webadmins
    /etc/sudoers.d/webadmins
    %webadmins ALL=(root) /usr/bin/systemctl restart httpd, /usr/bin/systemctl status httpd, /usr/bin/journalctl -u httpd
  4. backup1 without a password for rsync.
    useradd backup1
    visudo -f /etc/sudoers.d/backup1
    /etc/sudoers.d/backup1
    backup1 ALL=(root) NOPASSWD: /usr/bin/rsync
  5. Test as web1.
    su - web1
    sudo -l
    sudo systemctl status httpd
    sudo cat /etc/shadow
    exit
  6. Check the syntax of all files.
    visudo -c

Mijn notities

Nog geen notities.

Lessen voor dit lab

Commando's in dit lab