Skip to content

Instantly share code, notes, and snippets.

@antlauzon
Created August 9, 2018 07:10
Show Gist options
  • Save antlauzon/e2f4d271f2d7c8b18625a804f6eb32e6 to your computer and use it in GitHub Desktop.
Save antlauzon/e2f4d271f2d7c8b18625a804f6eb32e6 to your computer and use it in GitHub Desktop.
Automate MacOS ssh-agent password entry
#!/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