How to fix 'sudo: no tty present and no askpass program specified' error?

前端 未结 26 1635
失恋的感觉
失恋的感觉 2020-11-22 03:36

I am trying to compile some sources using a makefile. In the makefile there is a bunch of commands that need to be ran as sudo.

When I compile the sour

相关标签:
26条回答
  • 2020-11-22 04:21

    In Jenkins:

    echo '<your-password>' | sudo -S command
    

    Eg:-

    echo '******' | sudo -S service nginx restart
    

    You can use Mask Password Plugin to hide your password

    0 讨论(0)
  • 2020-11-22 04:22

    I think I can help someone with my case.

    First, I changed the user setting in /etc/sudoers referring to above answer. But It still didn't work.

    myuser   ALL=(ALL) NOPASSWD: ALL
    %mygroup  ALL=(ALL:ALL) ALL
    

    In my case, myuser was in the mygroup.

    And I didn't need groups. So, deleted that line.

    (Shouldn't delete that line like me, just marking the comment.)

    myuser   ALL=(ALL) NOPASSWD: ALL
    

    It works!

    0 讨论(0)
提交回复
热议问题