diff --git a/.functions.sh b/.functions.sh index 141ac6b..8943ad9 100644 --- a/.functions.sh +++ b/.functions.sh @@ -1,5 +1,17 @@ #!/bin/bash +function k3sudo(){ + # create a passwordless sudo rule on target + # usage: k3sudo [add, del] + if [[ "$1" == "add" ]];then + ssh -t $2 "hostname --long; echo \"$USER ALL=(ALL) NOPASSWD: ALL\" | sudo tee /etc/sudoers.d/k3sup" + elif [[ "$1" == "del" ]];then + ssh $2 sudo rm /etc/sudoers.d/k3sup + else + echo "Error: usage: k3sudo [add, del] " + fi +} + function pc(){ # use pass and copy to clipboard pass -c1 "$@"