I'm on arch and am using a network namespace wiredlan for ethernet, using it for LAN based applications and big downloads. I run commands/apps on the netns as:

alias runonlan='sudo ip netns exec wiredlan sudo -u me --' 
runonlan command

This works, but I want to be able to run it without having to enter password, to make things easier. But as the command part of runonlan command varies, I can't figure out what to put in sudoers in order to make it run without prompting for password.

So, I tried editing sudoers, adding (one at a time):

me ALL=(ALL) NOPASSWD: /bin/ip *
me ALL=(ALL) NOPASSWD: /bin/ip netns
me ALL=(ALL) NOPASSWD: /bin/ip netns exec wiredlan
me ALL=(ALL) NOPASSWD: /bin/ip netns exec wiredlan sudo -u me --

but it still asks for the password. What am I doing wrong? Is this even possible?

  • Try entering complete command ,me ALL=(ALL) NOPASSWD: ip netns exec wiredlan – Bharat Sep 9 '18 at 12:11
  • 1
    Also check sequence of rules in sudoers , unix.stackexchange.com/questions/18830/… – Bharat Sep 9 '18 at 12:20
  • @Bharat That's what the problem is, I can't put the complete command, as what follows after runonlan varies according to what I want to run on the LAN. I'll edit the question to make it clearer. – aksh1618 Sep 9 '18 at 16:28
  • Another option is to start an xterm as your normal user in the namespace (which needs a password once), and then you can issue commands on the xterm. I like to have a different background for these, in order to not accidently confuse them with my normal xterms. – dirkt Sep 9 '18 at 17:12
  • @dirkt Yes, currently I use runonlan tmux -L wiredlantmux and have an indicator in the prompt for the namespace. – aksh1618 Sep 10 '18 at 10:43

Your Answer

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

Browse other questions tagged or ask your own question.