0

I treied to execute the sudo command from the remote sertver but it is giving an error [u'sudo: no tty present and no askpass program specified\n']

  • Welcome to Stackoverflow. The better structured, described and formal correct your question is, the better answers you will get. Also try to use the editor, which offers possibilities to structure your question better. – Steffen Moritz Jun 17 '19 at 14:58

1 Answers1

2

try echo <password> | sudo -S <cmd>.

this is from the sudo manual:

The -S (stdin) option causes sudo to read the password from the standard input instead of the terminal device. The password must be followed by a newline character

Adam.Er8
  • 12,675
  • 3
  • 26
  • 38
  • also note that hard-coded passwords can be risky: https://www.beyondtrust.com/resources/glossary/hardcoded-embedded-passwords – Adam.Er8 Jun 17 '19 at 14:39