脚本报错:sudo: no tty present and no askpass program specified

sudo will only run a program as a different user if one of these 3 conditions has been met (as far as passwords are concerned):

  1. the NOPASSWD option is specified
  2. the user entered the correct target password
  3. the user entered the correct source password

Since options 2 and 3 require a TTY (sudo won't read from a pipe) it won't run if it can't find one. Check your script if at any point you're running a script remotely using ssh, as it's possible that it won't allocate a TTY for a non-interactive remote command.

你可能感兴趣的:(sudo)