Last active
January 29, 2018 00:33
-
-
Save ileathan/e10ce11f4788d6c67e76e5d928909d75 to your computer and use it in GitHub Desktop.
Run sudo command on remote machine non-interactively
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# USAGE: | |
# ./remote-sudo.sh password hostname command | |
HOST=$2; | |
PASSWORD=$1; | |
COMMAND="${@:3}" | |
ssh -T $HOST "echo $PASSWORD | sudo -S su -c \"$COMMAND\"" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment