Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo

agnos.is Forums

  1. Home
  2. Linux
  3. root (or sudo) access delay instead of password

root (or sudo) access delay instead of password

Scheduled Pinned Locked Moved Linux
linux
26 Posts 18 Posters 0 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • dontblink@feddit.itD [email protected]

    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?

    deadcatbounce@reddthat.comD This user is from outside of this forum
    deadcatbounce@reddthat.comD This user is from outside of this forum
    [email protected]
    wrote on last edited by
    #17

    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)!

    m33@theprancingpony.inM 1 Reply Last reply
    0
    • M [email protected]

      I'm curious, why do people make these comments? If the op wanted an answer from an LLM, they would have asked an LLM...

      N This user is from outside of this forum
      N This user is from outside of this forum
      [email protected]
      wrote on last edited by
      #18

      A modern equivalent of let me google that for you, but a more obnoxious one

      1 Reply Last reply
      0
      • deadcatbounce@reddthat.comD [email protected]

        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)!

        m33@theprancingpony.inM This user is from outside of this forum
        m33@theprancingpony.inM This user is from outside of this forum
        [email protected]
        wrote on last edited by
        #19
        @deadcatbounce @dontblink That's the Linux version of "press ALT+F4 to enable cheatmode" 🤣
        deadcatbounce@reddthat.comD 1 Reply Last reply
        0
        • T [email protected]

          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:

          1. Open the terminal and run:

            sudo visudo
            
          2. Locate the line:

            Defaults env_reset
            
          3. 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 to 0 requires a password every time, while a negative value disables the timeout entirely.

          L This user is from outside of this forum
          L This user is from outside of this forum
          [email protected]
          wrote on last edited by
          #20

          And did you verify this before posting?

          1 Reply Last reply
          0
          • M [email protected]

            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 configure sudo to allow execution of that command
            without password.

            M This user is from outside of this forum
            M This user is from outside of this forum
            [email protected]
            wrote on last edited by
            #21

            Rare seeing someone using C for automation rather then Python

            M 1 Reply Last reply
            0
            • m33@theprancingpony.inM [email protected]
              @deadcatbounce @dontblink That's the Linux version of "press ALT+F4 to enable cheatmode" 🤣
              deadcatbounce@reddthat.comD This user is from outside of this forum
              deadcatbounce@reddthat.comD This user is from outside of this forum
              [email protected]
              wrote on last edited by
              #22

              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]

              m33@theprancingpony.inM 1 Reply Last reply
              0
              • deadcatbounce@reddthat.comD [email protected]

                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]

                m33@theprancingpony.inM This user is from outside of this forum
                m33@theprancingpony.inM This user is from outside of this forum
                [email protected]
                wrote on last edited by
                #23
                @deadcatbounce
                1 Reply Last reply
                0
                • M [email protected]

                  Rare seeing someone using C for automation rather then Python

                  M This user is from outside of this forum
                  M This user is from outside of this forum
                  [email protected]
                  wrote on last edited by
                  #24

                  You cannot write setuid scripts. It must be a binary.

                  M 1 Reply Last reply
                  0
                  • M [email protected]

                    You cannot write setuid scripts. It must be a binary.

                    M This user is from outside of this forum
                    M This user is from outside of this forum
                    [email protected]
                    wrote on last edited by
                    #25

                    Ohh now I get it

                    1 Reply Last reply
                    0
                    • ? Guest

                      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 🙂

                      ? Offline
                      ? Offline
                      Guest
                      wrote on last edited by
                      #26

                      If an untrusted user is sitting at the console of a sudoer account, armed with its password, all is lost and any security has effectively been defeated already. While I do understand the concern it seems like something of a moot point.

                      1 Reply Last reply
                      0
                      • System shared this topic on
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups