I'd like to execute some sudo privilege commands using bash script from local to remote server via ssh without passing multiple commands separating from semicolons on ssh.
I've tried below step but got error.
ssh -t user@remoteip 'bash -s' < services.sh
Though I've used -t option here it still shows error message.
sudo: sorry, you must have a tty to run sudo
Best Answer
This can occur when
Defaults requiretty
is uncommented in/etc/sudoers
.The fix is to comment that line:
Remember to only edit
/etc/sudoers
using thevisudo
** command.**The
visudo
command may only be run by theroot
user.