First, not all attacks require to know the password. Many attacks against services (or daemons) target vulnerabilities in code and end in executing code on behalf of a user without knowing the password. In that case, the default sudo
configuration adds security by requiring the knowledge of the password.
Another example in a multi-user environment is when a user leaves his terminal unattended (you and I know that it is bad and never do it ourselves, but...) an attacker can execute commands on behalf of the user but still cannot use sudo
.
Finally, as you speak of ssh
, the common use is to only use a (RSA) key for user authentication. That way, the ssh
connection never use the password, which is only used for a direct local connection or to gain root access via sudo
. It can even be forced by disabling the use of the password in sshd
configuration. In the case of a remote server, the local user password is then indeed only used to gain root access.
But the real answer to your question is the option does exist! The /etc/sudoers
file can be used to declare the boolean flag rootpw
. If this flag is set, the password shall be the password for root instead of the password for the current user.
If the sudoers
contains the line:
Defaults rootpw
then you will be asked for the root password. This flag is off by default and is seldom used because it is not really sudo
philosophy but su
one: if you do know the password for root, you can directly use su
by-passing all additional sudo
controls.
sudo
is indeed a highly versatile command, and you really should read man sudoers