View on GitHub

Tristan Hill

Blog about IT related stuff

different github deploy keys

This litte script set in GIT_SSH switches based on the repository name

#!/bin/sh
set -e

echo "$2" >&2
for SUFFIX in "'" ".git'"; do
  BASENAME="$(basename "$2" "$SUFFIX")"
  [ -f "$HOME/.ssh/$BASENAME" ] && break
done
KEY="$HOME/.ssh/id_ecdsa_$BASENAME"
exec ssh -i "$KEY" "$@"