sudoers NOPASSWD: sudo: no tty present and no askpass program specified

前端 未结 3 1233
一向
一向 2021-01-04 20:07

I have added a user like this:

$ adduser --system --home /no/home --no-create-home --group --disabled-password --disabled-login testuser

Ad

相关标签:
3条回答
  • 2021-01-04 20:25

    I fixed it by login to the server and append the following lines to the ssh-server configuration:

    > vim /etc/ssh/sshd_config
    
    Match User <your user name>
        PermitTTY yes
    

    So I don't need the -t options permanently.

    0 讨论(0)
  • 2021-01-04 20:31

    sudo permissions are about the user/group you are changing from not the user you are changing to.

    So are those permission lines are letting the testuser user and the testgroup group run any command (as anyone) without a password.

    You need to give permission to the user running the script to run commands as the testuser user for what you want.

    Assuming that's what you meant to allow that is.

    0 讨论(0)
  • That error occurs when your sudoers file specifies requiretty. From the sudoers manpage:

       requiretty      If set, sudo will only run when the user is 
                       logged in to a real tty.  When this flag is set, 
                       sudo can only be run from a login session and not 
                       via other means such as cron(8) or cgi-bin scripts.  
                       This flag is off by default.
    

    To fix your error, remove requiretty from your sudoers file.

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