How to run sudo commands under a script?

Hi,

I am new to scripting. I am trying to write a script to ssh one remote machine and run a sudo command.

ssh <hostname> sudo -S <command> < ~/pass.txt

I am stored my password in pass.txt.
I am getting error

sudo: no tty present and no askpass program specified

Please suggest me how can i do this

Hi,

Try this one,

ssh -t ........

Cheers,
Ranga :slight_smile: