Skip to content

Instantly share code, notes, and snippets.

@lookfirst
Created November 6, 2021 01:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lookfirst/370f4752b1265e86e256ba431a60aa84 to your computer and use it in GitHub Desktop.
Save lookfirst/370f4752b1265e86e256ba431a60aa84 to your computer and use it in GitHub Desktop.
keywords: sshpass sudoers nopasswd ubuntu
#!/usr/bin/env bash
export SSHPASS="1"
sshpass -e ssh -o "UserKnownHostsFile=/dev/null" -o StrictHostKeychecking=no -o LogLevel=ERROR user@$1 \
"echo $SSHPASS | sudo -S bash -c 'echo \"user ALL=(ALL) NOPASSWD:ALL\" > /etc/sudoers.d/00-user_nopasswd' 2> /dev/null"
@lookfirst
Copy link
Author

echo "user ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/00-user_nopasswd

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment