Skip to content

Instantly share code, notes, and snippets.

@fiznool
Created May 20, 2015 21:25
Show Gist options
  • Star 25 You must be signed in to star a gist
  • Fork 7 You must be signed in to fork a gist
  • Save fiznool/88442338db96a898f1dc to your computer and use it in GitHub Desktop.
Save fiznool/88442338db96a898f1dc to your computer and use it in GitHub Desktop.
#!/bin/bash
if [ "$GIT_SSH_KEY" != "" ]; then
echo "Cleaning up SSH config" >&1
echo "" >&1
# Now that npm has finished running,
# we shouldn't need the ssh key/config anymore.
# Remove the files that we created.
rm -f ~/.ssh/config
rm -f ~/.ssh/deploy_key
# Clear that sensitive key data from the environment
export GIT_SSH_KEY=0
fi
#!/bin/bash
if [ "$GIT_SSH_KEY" != "" ]; then
echo "Detected SSH key for git. Adding SSH config" >&1
echo "" >&1
# Ensure we have the ssh folder
if [ ! -d ~/.ssh ]; then
mkdir -p ~/.ssh
chmod 700 ~/.ssh
fi
# Load the private key into a file.
echo $GIT_SSH_KEY | base64 --decode > ~/.ssh/deploy_key
# Change the permissions on the file to
# be read-write for this user.
chmod 600 ~/.ssh/deploy_key
# Setup the ssh config file.
# Switch out the hostname for different hosts.
echo -e "Host github.com\n"\
" IdentityFile ~/.ssh/deploy_key\n"\
" IdentitiesOnly yes\n"\
" UserKnownHostsFile=/dev/null\n"\
" StrictHostKeyChecking no"\
> ~/.ssh/config
fi
@shubham1144
Copy link

If trying to connect to bitbucket..please use 'bitbucket.org' instead of 'github.com'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment