Created
August 9, 2018 07:10
-
-
Save antlauzon/e2f4d271f2d7c8b18625a804f6eb32e6 to your computer and use it in GitHub Desktop.
Automate MacOS ssh-agent password entry
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 | |
IFS=' | |
' | |
for key in $(cat ~/.ssh/keys); do | |
ssh-add -l | grep -E "$key |$key.fifo" > /dev/null | |
if [[ $? != 0 ]]; then | |
if [ ! -f $key.pass ]; then | |
ssh-add $key | |
else | |
rm $key.fifo | |
mkfifo -m 0600 $key.fifo | |
cat $key > $key.fifo | SSH_ASKPASS="$key.pass" ssh-add $key.fifo | |
fi | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment