Created
May 20, 2015 21:25
-
-
Save fiznool/88442338db96a898f1dc to your computer and use it in GitHub Desktop.
Private Repository Deployment. As seen at http://fiznool.com/blog/2015/05/20/an-alternative-to-npm-private-modules/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If trying to connect to bitbucket..please use 'bitbucket.org' instead of 'github.com'