kevin@myComputer:~$ sudo -i [sudo] password for kevin: @myComputer:~# env | wc -l 34 @myComputer:~# exit logout kevin@myComputer:~$ sudo su - @myComputer:~# env | wc -l 26 @myComputer:~# exit logout
kevin@myComputer:~$ sudo -i @myComputer:~# env > ~kevin/sudo_-i.txt && logout kevin@myComputer:~$ sudo su - @myComputer:~# env > ~kevin/sudo_su_-.txt @myComputer:~# diff ~kevin/sudo_-i.txt ~kevin/sudo_su_-.txt 2,4c2 < COLORTERM=truecolor < SUDO_GID=1000 < LANGUAGE=en_EN.UTF-8 --- > LANGUAGE=en 7d4 < SUDO_COMMAND=/bin/bash 9d5 < SUDO_USER=kevin 12d7 < XAUTHORITY=/home/kevin/.Xauthority 14d8 < LANG=en_US.UTF-8 15a10 > LANG=en_US.UTF-8 17d11 < XDG_CURRENT_DESKTOP=XFCE 23d16 < DISPLAY=:0.0 30,31c23 < PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin :/snap/bin spaces added to compare with the line below < SUDO_UID=1000 --- > PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
~ : these are often editor backup files. : these are often editor temporary files$username ALL=(root) NOPASSWD:$(which whoami)" > "$sudoersFile"; su - "$username" -c "whoami; sudo whoami"; [ -f "$sudoersFile" ] && rm "$sudoersFile"; userdel -r "$username"bob
# disable password logins PasswordAuthentication no ChallengeResponseAuthentication no # OpenSSH <8.7 (Debian) KbdInteractiveAuthentication no # OpenSSH 8.7+ PubkeyAuthentication yes
PermitRootLogin prohibit-password
PermitRootLogin no Match Address 127.0.0.1 PermitRootLogin prohibit-password
Match directives should be found at the bottom of the file.TODO: * check if it's possible to specify both : from="12.34.56.78" command="cmd" ssh-ed25519 key * some docs mention "PermitRootLogin forced-commands-only" as a prerequisite...
bob ALL=() /bin/su to /etc/sudoers.d/bob.:!$6$fRTcws15$d7doaLc.WNnUK/4l4mHTnA......Read more about
! and * in the password field of /etc/shadow
This is potentially granting too many rights !
As :# Allow members of group sudo to execute any command %sudo ALL=(ALL:ALL) ALL
bob ALL=() NOPASSWD:/usr/sbin/service
>>> /etc/sudoers.d/bob: syntax error near line 1 <<< sudo: parse error in /etc/sudoers.d/bob near line 1 sudo: no valid sudoers sources found, quitting sudo: unable to initialize policy plugin
[space] and [TAB] indentation are supported%sudo ALL=(ALL:ALL) ALL
stands for :
who where = (as_whom) what
%groupName) receiving extra privilegesALLrunAsUser:runAsGroup