Skip to content

Instantly share code, notes, and snippets.

@jcefoli
Created October 11, 2021 04:50
Show Gist options
  • Save jcefoli/eca0c6a7b46361e8d2671cb08b04cb70 to your computer and use it in GitHub Desktop.
Save jcefoli/eca0c6a7b46361e8d2671cb08b04cb70 to your computer and use it in GitHub Desktop.
Remove password prompt from sudo elevation, with paranoia checks (Ubuntu 20.04 LTS)
#!/usr/bin/env bash
cp --no-preserve=mode,ownership /etc/sudoers /etc/sudoers.tmp
sed -i "s/%sudo\tALL=(ALL:ALL) ALL/%sudo\tALL=(ALL) NOPASSWD: ALL/g" /etc/sudoers.tmp
visudo -c -f /etc/sudoers.tmp
if [ "$?" -eq "0" ]; then
cp /tmp/sudoers.tmp /etc/sudoers
else
echo "Something went wrong"
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment