kevin@myComputer:~$ sudo -i [sudo] password for kevin: root@myComputer:~# env | wc -l 34 root@myComputer:~# exit logout kevin@myComputer:~$ sudo su - root@myComputer:~# env | wc -l 26 root@myComputer:~# exit logout
kevin@myComputer:~$ sudo -i root@myComputer:~# env > ~kevin/sudo_-i.txt && logout kevin@myComputer:~$ sudo su - root@myComputer:~# env > ~kevin/sudo_su_-.txt root@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 root
# 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=(root) /bin/suto /etc/sudoers.d/bob.
root:!$6$fRTcws15$d7doaLc.WNnUK/4l4mHTnA......
Read more about !
and *
in the password field of /etc/shadow
This is potentially granting too many rights !
As root :# Allow members of group sudo to execute any command %sudo ALL=(ALL:ALL) ALL
bob ALL=(root) 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 privilegesALL
runAsUser:runAsGroup