Enable Passwordless Sudo with Arguments

I am trying to enable passwordless sudo for updating yum on a RHEL box. I have the following line in sudo visudo.

myuser ALL=(ALL) NOPASSWD: /usr/bin/yum update

After doing this under myuser I am still unable to update yum without giving my sudo password.

  • /usr/bin/env sudo yum -y update
  • sudo yum -y update

The reason why I need this done is because in Capistrano 3 it says this is the best way. It does not seem to allow a prompt of sudo anymore.

Answer

Actually, the command string listed in the sudoers is requiring to be the exact match.

In your example, you put the command string /usr/bin/yum update in the sudoers configuration line, but the command you finally executes is yum -y update. (the difference is the extra parameter -y).

Then, the mismatch in command string caused the sudoers failed to hit the designed definition.

So, the following ways are my suggestion to rectify the problem:

  1. use the command string /usr/bin/yum -y update when you setting the sudoer configuration, or

  2. use the command string /usr/bin/yum (no parameter in there).

Attribution
Source : Link , Question Author : wallerjake , Answer Author : Cristian Ciupitu

Leave a Comment