Skip to content

Instantly share code, notes, and snippets.

@squeedee
Last active March 6, 2019 15:11
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 squeedee/eb828bcc6a6a0276dcc3886531ec3c7a to your computer and use it in GitHub Desktop.
Save squeedee/eb828bcc6a6a0276dcc3886531ec3c7a to your computer and use it in GitHub Desktop.
Script to add your github ssh key to any github requests. Great for concourse tasks with private golang modules.
#!/usr/bin/env bash
if [[ -z "${GITHUB_KEY}" ]] ; then
echo "GITHUB_KEY not defined"
exit 1
fi
mkdir -p $HOME/.ssh
chmod 700 $HOME/.ssh
echo "${GITHUB_KEY}" > $HOME/.ssh/id_github
echo "Host github.com" >> $HOME/.ssh/config
echo " HostName github.com" >> $HOME/.ssh/config
echo " User git" >> $HOME/.ssh/config
echo " IdentityFile ~/.ssh/id_github" >> $HOME/.ssh/config
echo " StrictHostKeyChecking no" >> $HOME/.ssh/config
chmod 600 $HOME/.ssh/*
git config --global url."git@github.com:".insteadOf "https://github.com/"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment