Skip to content

Instantly share code, notes, and snippets.

@presbrey
Created January 9, 2012 16:44
Show Gist options
  • Save presbrey/1583792 to your computer and use it in GitHub Desktop.
Save presbrey/1583792 to your computer and use it in GitHub Desktop.
gitosis gssapi wrapper: map kerberos principal to gitosis user
#!/bin/bash
# gitosis-serve-krb5
#
# map kerberos principal to gitosis user (and strip @REALM.COM)
#
# [/etc/ssh/sshd_config]
# Match User git
# ForceCommand gitosis-serve-krb5
klist=`klist -5`
if [[ $? -eq 0 ]]; then
user=`klist -5 2>/dev/null | awk '/Default principal:/ {print $3}' | cut -d@ -f1`
if [[ ! -z "$user" ]]; then
exec gitosis-serve $user
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment