Tag Info

New answers tagged

0

If your sudoers file sets the requiretty option, then you can only call sudo from a terminal. If your sudoers file doesn't set the requiretty option, then you can call sudo from anywhere, but if it prompts for a password, a terminal is required. The message “sudo: no tty present and no askpass program specified” indicates that sudo tried to prompt you for a ...


0

It seems that, for some mysterious reason, restarting openssh made the trick....


0

sudo is not using regular expression, it is using standard shell glob patterns. So for blocking an IPv4 address you must use: blockuser ALL=NOPASSWD:/usr/sbin/ufw deny from [0-9]*[0-9]*[0-9]*[0-9]* to any \. is not allowed


-1

Adding to Anthon's answer, if you have root access to the server, you can add NOPASSWD: in the line where you have defined your user in /etc/sudoers. Once NOPASSWD: is added, sudo won't prompt you for the password. If this is your current line: myuser ALL=(ALL) <commands> change it to: myuser ALL=(ALL) NOPASSWD: <commands> P.S: Use ...


3

What you are looking for is sudo -v. From the man page: -v, --validate Update the user's cached credentials, authenticating the user if necessary. (And the counterpart to explicitly remove the credentials: sudo -k)


1

Yes, that's perfectly fine. A lot of common utilities do that. You should however have some fallback in case the application does not get sudo - but that's just good script writing. Another way to do things like these, that I do not recommend, is to ask the user to run the application as root, which is bad. So this alternative is better. Also make sure that ...


6

This is a choice. If you don't like it, you can use the -i or -H option, or change the configuration. The sudo(8) man page says for HOME: Set to the home directory of the target user if -i or -H are specified, env_reset or always_set_home are set in sudoers, or when the -s option is specified and set_home is set in sudoers. Actually env_reset doesn't ...


5

The point of a “graphical sudo” is to prompt for the user's password. If you don't want a password prompt, use plain sudo. Run visudo to create an entry in the sudoers file with the NOPASSWD tag. Note that this entry must come after any ALL entry. Make sure that the DISPLAY and XAUTHORITY environment variables are preserved, to allow running X11 ...


1

You can use SSH with X forwarding (-X) and a key without password. SSH has the useful feature that keys can be limited to one command. This could be a kind of sudo replacement: Prevent the user from doing as root what he wants; limit him to what he must be capable of doing.


2

You can specify a transition in a custom policy file (.te) like this: module collectdlocalexec 1.0; require { type collectd_t; type user_home_t; type unconfined_t; type shell_exec_t; class capability {setgid setuid }; class file { execute read open }; class process transition; } allow collectd_t ...


2

In Linux, once a parent process is killed its child process becomes an orphan. But then the "warm hearted" init process adopts that orphan process which allows it to proceed. In order to kill parent and its children processes you can use: pkill -TERM -P <parent's PID> (Note: orphan process is different from zombie process, but that's for another ...


3

The parent (sudo) is notified that the child process has exited. As the only purpose of the parent was to run this child process it terminates. Other processes would not terminate just because you kill a child process. On the other hand the child doesn't care what the parent process does. The parent could even terminate immediately after the child process ...


4

Test if you are root, and if not, restart with sudo, for example: #! /bin/bash if [[ $EUID -ne 0 ]]; then exec sudo /bin/bash "$0" "$@" fi


1

I believe what you are trying to accomplish is making sure the user runs a script as root. To do this, you do not want to add it to the script, but instead just change the ownership of the file and the execute permissions. This can be done with: # chmod og-rx yourscript.sh # chown root:root yourscript.sh (by muru =]) or # chmod 750 yourscript.sh # ...


3

Try: Defaults timestamp_timeout=0 An example from man 5 sudoers, where a value is appended to an option: Defaults env_keep += "DISPLAY HOME"


3

traceroute need not run as root; it just needs the capability CAP_NET_ADMIN. Thus you can set this as file capability for the file and then traceroute will always have this capability (for all users, though), if your kernel supports file capabilities and no Linux Security Module (SELinux, AppArmor) is blocking it: setcap CAP_NET_ADMIN+ep ...


-1

How about adding traceroute to the sudoers file ? Use visudo to do it. Should look like something like that #Allow traceroute for users yourUser ALL=NOPASSWD: /usr/bin/traceroute Note that without the -d, you can use traceroute without root privileges ...


1

No Sudo Option You can use the source command to run another bash script in the same environment you came from. (Without launching a subprocess) Script1.sh #!/bin/bash read -p "Enter Your Full Name: " Name source script2.sh Script2.sh #!/bin/bash echo $Name -- With Sudo The reason your example doesn't work is because of the sudo. You can use Sudo ...


1

It only checks access when you issue a specific command: sudo. It doesn't check for just any command whether you have the right to run it with root privileges. The sudo elevates your privileges then runs the other commands as such, without needing any additional checks. Quite often the setup is such that you have to be member of the sudo group (e.g. ...


0

On Red Hat Enterprise Linux (RHEL) 6 /etc/ld.so.conf contains include ld.so.conf.d/*.conf without this line, items in /etc/ld.so.conf.d/*.conf would never be parsed. To see which libraries / directories ldconfig is parsing ldconfig -v Print current version number, the name of each directory as it is scanned, and any links that are created.


1

Add the following to your .bashrc: vim ~/.bashrc ... export LD_LIBRARY_PATH=/usr/local/lib This will let you restart your computer, and still have that path assigned.


4

When a user invokes sudo -l it lists what sudo will allow them to do, so you could have a script ran as root that bumps through /etc/passwd and sudo's to each user, invoke the sudo -l, directing the output to /tmp/${USER}_sudo_i_can_do.txt But if you don't have root access, you won't be able to do what you want to do; the list of permissions is readable ...


3

sudo command requires password of current user, not root user. If you wish to authorize by root password you can just use su -.


1

This is too complicated for sudoers. You have to write a script which checks whether the user belongs to this group and calls passwd if so. sudoers must then be configured so that john can run this script as root. Of course, the path to this script must be writable only for root. #! /bin/bash group="groupname" test $# -ne 1 && exit 2 user="$1" ...


0

Add /usr/local/lib to /etc/ld.so.conf and run ldconfig, then you'll have this path added as a default path for libraries.


3

Allowing LD_LIBRARY_PATH for suid binaries like sudo is a security problem, thus LD_LIBRARY_PATH gets stripped out of the environment. sudo by default doesn't passthrough LD_LIBRARY_PATH to its children either for the same security concerns: carefully crafted libraries would allow you to bypass the sudo argument restrictions to execute whatever you want. If ...


0

Figured it out. Here is my functional script: #!/bin/bash ADMIN_PASS="$(cat /Users/adminuser/Documents/UpdateScript/enPass.txt)" ADMIN_USER="adminuser" HOST_LIST="/Users/adminuser/Desktop/hosts.txt" for HOST in $(< $HOST_LIST); do echo "" echo "--------------------------------" echo "# CONNECTING TO: $HOST #" echo ...


2

If you want to be allowed to run commands as root, but be prompted to enter your own password, then edit the sudo configuration by running the visudo program. This brings up your favorite text editor to edit the sudo configuration file. Look for the line that authorizes you to run commands as root and remove the text NOPASSWD: from that line. Save the file ...



Top 50 recent answers are included