I tried this:
#!bin/bash
ssh user@host.com 'sudo /etc/init.d/script restart'
But I get this error:
sudo: no tty present and no askpass program specified
How can I run that script? Now when I need to run that script I do these steps:
ssh user@host.com
sudo /etc/init.d/script restart
But I don't want to manually log in to remote server all the time and then enter restart command.
Can I write local script that I could run so I would only need to enter password and it would run remote script and restart the process?
You can use
-t
option inssh
command to attach a pseudo-tty with yourssh
command:As per
man ssh
: