Skip to content

Instantly share code, notes, and snippets.

@grizmio
Created December 21, 2021 00:24
Show Gist options
  • Save grizmio/f0d5333899bafe8fd17063992b4bfe8a to your computer and use it in GitHub Desktop.
Save grizmio/f0d5333899bafe8fd17063992b4bfe8a to your computer and use it in GitHub Desktop.
Please, never, ever, use me
#!/bin/bash
export SSH_AUTH_SOCK=$HOME/.ssh/ssh-agent.$(hostname).sock
env |grep -q "^DISPLAY="
if [ $? -ne 0 ] ; then
export DISPLAY=:0
fi
pidof ssh-agent >/dev/null 2>&1
DONTSTOREMEHERE="PECO"
if [ $? -ne 0 ]; then
if [ ! -e $HOME/ssh_give_pass.sh ] ; then
/bin/echo -e '#!/bin/bash\nread SECRET\necho $SECRET\n' > $HOME/ssh_give_pass.sh
chmod +x $HOME/ssh_give_pass.sh
fi
ssh-agent -a "$SSH_AUTH_SOCK"
sleep 1
SSH_ASKPASS=$HOME/ssh_give_pass.sh ssh-add $HOME/.ssh/id_ed25519 <<< "$DONTSTOREMEHERE"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment