title: shell script giving "sudo: no tty present and no askpass program specified" when trying to execute sudo command
body: <ul>
  <li><p>I have a shell script which creates a user and executes another script as  that user</p>
  
  <pre><code>sudo useradd -m devops
  sudo passwd devops
  sudo adduser devops sudo  
  su - devops -c "sh /path/to/myscript.sh"
  </code></pre></li>
  <li><p>This script creates the user,sets the password and adds user to sudo group as expected.</p></li>
  <li>myscript.sh contains commands which uses sudo previlages. (sudo apt-get update, sudo apt-get install software-properties-common etc.). And other commands like ssh-keygen,curl and wget.</li>
  <li>All commands except the one's with sudo are executed correctly and producing results as excepted. </li>
  <li>But commands having sudo fails by giving the error <strong>"no tty present and no askpass program specified"</strong></li>
  <li>Why does this happen in this case and how can I overcome this?</li>
  <li>I have seen similiar questions but will be thankful if I get a clear explanation in this context,thank you.</li>
  </ul>