Skip to content

Instantly share code, notes, and snippets.

@itchyny
Last active November 27, 2019 01:46
Show Gist options
  • Save itchyny/7fb33a97fe257a594e06a74a0bc07af0 to your computer and use it in GitHub Desktop.
Save itchyny/7fb33a97fe257a594e06a74a0bc07af0 to your computer and use it in GitHub Desktop.
shell alias to use specific identity file on git push
# Example: git-ssh-key ~/path/to/identity-file git push origin master
git-ssh-key() {
ssh_key=${1:?Usage: git-ssh-key identity-file commands...}
shift
GIT_SSH_COMMAND=" \
ssh -F /dev/null \
-o IdentitiesOnly=yes \
-o IdentityFile=\"$ssh_key\" \
-o UserKnownHostsFile=/dev/null \
-o StrictHostKeyChecking=no \
" "$@"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment