Skip to content

Instantly share code, notes, and snippets.

@jpbochi
Created March 20, 2017 13:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jpbochi/f31f6378724a903d3b5c695bd1eac7ed to your computer and use it in GitHub Desktop.
Save jpbochi/f31f6378724a903d3b5c695bd1eac7ed to your computer and use it in GitHub Desktop.
#!/usr/bin/env sh
set -eu
eval $(ssh-agent -s)
KEYS=$(ls -p /var/ssh-keys/ | grep -v -e '/' -e config -e known_hosts -e '.pub$' -e authorized_keys)
echo "$KEYS" | xargs -I % ssh-add /var/ssh-keys/%
mkdir -p /root/.ssh
ssh-keyscan github.com >> /root/.ssh/known_hosts
echo 'host github.com' > /root/.ssh/config
echo ' HostName github.com' >> /root/.ssh/config
echo ' User git' >> /root/.ssh/config
echo "$KEYS" | sed 's/^/ IdentityFile \/var\/ssh-keys\//' >> /root/.ssh/config
$@
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment