Skip to content

Instantly share code, notes, and snippets.

@azenla
Last active August 29, 2015 14:25
Show Gist options
  • Save azenla/25f153a3904627d994cf to your computer and use it in GitHub Desktop.
Save azenla/25f153a3904627d994cf to your computer and use it in GitHub Desktop.
!/bin/bash
# travis_ssh_key_encrypt_for_mac.ssh
# Encrypts private SSH keys for use in .travis.yml.
# Based on the excellent linux version:
# https://gist.github.com/lukewpatterson/4242707
# Also see the travis documentation:
# http://docs.travis-ci.com/user/build-configuration/#Secure-environment-variables
# Usage:
# Go to your git project:
# cd my_project
# Then run:
# ./travis_key_encrypt.sh ~/.ssh/my_private_key
SSH_KEY_PATH=$1
base64 --break 64 ${SSH_KEY_PATH} > ${SSH_KEY_PATH}_base64
if [[ ! $(which travis) ]]
then
gem install travis
fi
travis login --pro --auto
for l in $(cat ${SSH_KEY_PATH}_base64);
do
LINE=$(grep -n $l ${SSH_KEY_PATH}_base64 | cut -d: -f1);
echo "- secure: $(travis encrypt \"travisci_$LINE=$l\")";
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment