Last active
August 18, 2016 11:25
-
-
Save ten0s/d93e7c62b19cff6c4be627e19288983a to your computer and use it in GitHub Desktop.
Multiple Github Deploy keys on single machine
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 | |
# http://eclipsesource.com/blogs/2012/07/30/accessing-multiple-private-github-repositories-without-a-dedicated-build-user/ | |
set -e | |
self=${0} | |
script_name=$(basename ${self}) | |
script_dir=$(dirname ${self}) | |
ssh_dir=${script_dir}/../common/ssh | |
if [[ $# < 1 ]]; then | |
echo "Generates repository Deploy key" | |
echo "https://developer.github.com/guides/managing-deploy-keys/#deploy-keys" | |
echo "Usage: ${script_name} <REPONAME>" | |
exit 1 | |
fi | |
reponame=${1} | |
if [[ -f ${ssh_dir}/id_rsa-${reponame} ]]; then | |
echo "Deploy key for ${reponame} already exists" | |
exit 1 | |
fi | |
ssh-keygen -t rsa -N "" -C "Deploy key for ${reponame}" \ | |
-f ${ssh_dir}/id_rsa-${reponame} | |
cat >>${ssh_dir}/config <<EOF | |
Host ${reponame}.github.com | |
HostName github.com | |
User git | |
IdentityFile ~/.ssh/id_rsa-${reponame} | |
EOF | |
echo | |
echo "Deploy key for ${reponame} generated." | |
echo "Now:" | |
echo "1. Go to ${reponame} -> Settings -> Deploy keys -> Add deploy key " | |
echo " and paste " | |
cat ${ssh_dir}/id_rsa-${reponame}.pub | |
echo "2. Run bin/images-build to rebuild the images" | |
echo "3. Push new images to the registry" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment