Created
May 26, 2025 08:37
-
-
Save santaklouse/bacd463a9ed5b1528104c5063979368f to your computer and use it in GitHub Desktop.
wrapper around ssh in order to use passwords in config (draft)
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
#!/usr/bin/env bash | |
#ORIG_SSH=/usr/bin/ssh | |
ORIG_SSH=/opt/homebrew/bin/ssh | |
HOST=$1 | |
SSHPASS=$(ggrep -Pzo "Host $HOST"'\s*\n((?!Host).*\n)*\s*#PS\s(\N+)\n' ~/.ssh/config|tail -n 2|head -n 1 | sed 's/ *#PS //') | |
if [ -n $SSHPASS ]; then | |
sleep 1 | |
else | |
unset args opts; | |
for args; do | |
if [[ $a == [-]* ]]; then | |
opts+=("$a"); | |
else | |
if grep -F "$a" ~/.ssh/config; then | |
# code if found | |
#HOST=$a | |
# echo "p: $a" | |
SSHPASS=$(ggrep -Pzo "Host $a"'\s*\n((?!Host).*\n)*\s*#PS\s(\N+)\n' ~/.ssh/config|tail -n 2|head -n 1 | sed 's/ *#PS //') | |
fi | |
args+="$a"; | |
fi; | |
done; | |
fi; | |
#SSHPASS=$(ggrep -Pzo "Host $HOST"'\s*\n((?!Host).*\n)*\s*#PS\s(\N+)\n' ~/.ssh/config|tail -n 2|head -n 1 | sed 's/ *#PS //') | |
if [ -n $SSHPASS ]; then | |
# echo $SSHPASS | |
export SSHPASS | |
# echo $ORIG_SSH | |
# echo $@ | |
sshpass -e $ORIG_SSH $@ | |
else | |
$ORIG_SSH $@ | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment