Run sudo Command over SSH. Single line.

When running an SSH command that uses sudo, something like

ssh admin@ "sudo apt -y update && sudo apt -y upgrade"

You may receive the following error.

sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper
sudo: a password is required

To work around this, you can use the -t option. -q is not needed, but makes thing quieter.

ssh -qt admin@ "sudo apt -y update && sudo apt -y upgrade "

The sudo password will also be hidden.

Leave a Reply

Your email address will not be published. Required fields are marked *