2

I have a shell script that calls dpkg, which obviously needs to be sudoed to do anything. I've added dpkg to the list of files in /etc/sudoers.d that no longer require a password (Bad idea, I know), but when I attempt to run my script, it still requests a password. The script is simply

sudo dpkg -i $1

When I run dpkg from a terminal, it doesn't require a password, but when I do it from my .sh file, it just requests a password right away.

Any suggestions or idea as to what I need to do beyond the sudoers.d addition?

2
  • That literally IS the entire script. There's nothing at all that it does beyond that. I've ran the script via sudo script.sh, added it to the sudoers.d, and it still requests the password.
    – Gyhth
    Aug 16, 2019 at 23:33
  • It starts with the #!/bin/sh. When I remove the sudo, it claims that it requires sudo before the dpkg. The goal is basically to pass in a path from another application, and then have it run the dpkg install to install the required package.
    – Gyhth
    Aug 17, 2019 at 12:35

1 Answer 1

0

So the solution was fairly simple. The issue is that the shebang line runs as a separate user account. As soon as I changed the username usergroup = (root)... to ALL ALL = (root)... in the /etc/sudoers.d directory, it then allowed us to run the script without requiring a password. Obvious security implications here, which need to be investigated, but this is outside the scope of the question I had originally asked.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .