From 1e30ec6541c021ec68a726356b3d23cdf57dd562 Mon Sep 17 00:00:00 2001 From: Jonas Forsberg Date: Thu, 20 May 2021 08:08:49 +0200 Subject: [PATCH] added k3sudo function --- .functions.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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 "$@"