1

On machine A and B (both running CentOS 7), I have:

# cat /etc/sudoers.d/custom
userA ALL=(userB:userB) NOPASSWD:ALL

However, on machine A, when I run

[userA] $ sudo -ui userB
sudo: unknown user: i
sudo: unable to initialize policy plugin

when I run

[userA] $ sudo -iu userB
sudo: unknown user: env
sudo: unable to initialize policy plugin

Tho, on machine B, both commands work fine.

userA and userB both exist on both machines.

Any idea?

Update 1 (based on @Bart's suggestion):

[userA]$ sudo -u -i userB
sudo: unknown user: -i
sudo: unable to initialize policy plugin
[userA]$ sudo -i -u userB
Need at least 3 arguments.
Run scl --help to get help.
[userA]$ sudo -u userB -i
Need at least 3 arguments.
Run scl --help to get help.

[userA]$ alias
alias egrep='egrep --color=auto'
alias fgrep='fgrep --color=auto'
alias grep='grep --color=auto'
alias l.='ls -d .* --color=auto'
alias ll='ls -l --color=auto'
alias ls='ls --color=auto'
alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'

1 Answer 1

1

You have to split the paramenters, otherwise it will not work. So, do:

sudo -i -u user
4
  • still doesn't work. see my update above.
    – HCSF
    Dec 22, 2021 at 12:32
  • ok, that is weird. What if you tried sudo -u userB -i . and also, the sudoers entry seems a little off, try userA ALL=(userB) NOPASSWD:ALL
    – Bart
    Dec 22, 2021 at 12:47
  • also, check your system for aliases towards sudo (simple alias command will give you the output). not sure why SCL is involved here, presumably you have installed something from the repo that interfered with sudo..
    – Bart
    Dec 22, 2021 at 12:49
  • updated my post. I also tried to have userA ALL=(userB) NOPASSWD:ALL instead. same outputs for all 3 commands.
    – HCSF
    Dec 22, 2021 at 14:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.