root (or sudo) access delay instead of password
-
Is there a way to require a user to wait a certain time instead of asking for a password every time he wants to execute a command as root or access the root / or another user account?
Yes; the command prefix that you're looking for is
shutdown now ; (followed by your sudo command if you wish)
It will provide the appropriate delay before using the root command via sudo or having logged again as root (sigh)!
-
I'm curious, why do people make these comments? If the op wanted an answer from an LLM, they would have asked an LLM...
A modern equivalent of let me google that for you, but a more obnoxious one
-
Yes; the command prefix that you're looking for is
shutdown now ; (followed by your sudo command if you wish)
It will provide the appropriate delay before using the root command via sudo or having logged again as root (sigh)!
-
Do you mean the delay between when you need to re-enter the superuser password?
I found this via an LLM:
To change the delay before needing to re-enter your
sudo
password, follow these steps:-
Open the terminal and run:
sudo visudo
-
Locate the line:
Defaults env_reset
-
Add the following line below it:
Defaults timestamp_timeout=<time-in-minutes>
Replace
<time-in-minutes>
with the desired timeout in minutes (e.g.,30
for 30 minutes). Setting it to0
requires a password every time, while a negative value disables the timeout entirely.
And did you verify this before posting?
-
-
Sure, though I advice against. The following C program can do that:
#include <stdio.h> #include <stdlib.h> #include <unistd.h> int main(int argc, char **argv) { if (argc < 2) { fprintf(stderr, "usage: %s <command> <args>...", argv[0]); return EXIT_FAILURE; } printf("Executing"); for (int i = 1; i < argc; ++i) { printf(" %s", argv[i]); } puts("\n^C to abort"); sleep(5); if (setuid(0)) { perror("setuid"); return EXIT_FAILURE; } execvp(argv[1], argv + 1); perror("exec: /sbin/lilo"); return EXIT_FAILURE; }
As seen in:
$ gcc -O2 -o delay-su delay-su.c $ sudo chown root:sudo delay-su $ sudo chmod 4750 delay-su $ ./delay-su id $ id -u 1000 $ ./delay-su id -u Executing id -u ^C to abort 0
This will allow anyone in group
sudo
to execute any command as root.
You may change the group to something else to control who exactly can
run the program (you cannot change the user of the program).If there’s some specific command you want to run, it’s better to
hard-code it or configuresudo
to allow execution of that command
without password.Rare seeing someone using C for automation rather then Python
-
Please don't desecrate my Linux with Windows talk.
Bleugh! I need a shower!
[The worst Linux users are ex Windows users; 2004 vintage here]
-
Please don't desecrate my Linux with Windows talk.
Bleugh! I need a shower!
[The worst Linux users are ex Windows users; 2004 vintage here]
-
Rare seeing someone using C for automation rather then Python
You cannot write setuid scripts. It must be a binary.
-
You cannot write setuid scripts. It must be a binary.
Ohh now I get it
-
In terms of security, an alias can be easily overridden by a user who can even choose yo use another shell which will not read .bashrc.
So this solution cannot force/require the user to comply to the delay requirement.
I was thinking maybe with a PAM module the delay can be achieved but I haven't found one that readily does that. Maybe OP needs to implement one
-