Skip to content

Instantly share code, notes, and snippets.

@zh4n7wm
Created April 17, 2017 08:06
Show Gist options
  • Save zh4n7wm/7343d2c1b8c99652847052c874c787a7 to your computer and use it in GitHub Desktop.
Save zh4n7wm/7343d2c1b8c99652847052c874c787a7 to your computer and use it in GitHub Desktop.
sudo: sorry, you must have a tty to run sudo
for x in $(cat hosts)
do
echo $x && ssh -t $x 'sudo grep -Pq "^\s*Defaults:centos\s+!requiretty\s*$" /etc/sudoers || sudo sed -i "/Defaults requiretty/a \
Defaults:centos !requiretty" /etc/sudoers ; exit'
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment