How to prompt for password when running command over ssh

To prompt for password when running a command over an ssh connect, allocate pseudo terminal using the -t flag

$ ssh -t remote.server "sudo reboot now"
[sudo] password for user:
Connection to remote.server closed.

Without using the -t flag, an error will appear:

$ ssh remote.server "sudo reboot now"
sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper
If you liked this posting, please feel free to leave me a comment below.
View this page on GitHub.
Posted .

Comments

Leave a Reply