Skip to content

Instantly share code, notes, and snippets.

@netj
Created April 26, 2014 04:36
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save netj/11311822 to your computer and use it in GitHub Desktop.
Save netj/11311822 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
# mosh-server wrapper for Kerberos/AFS home environment
#
# Author: Jaeho Shin <netj@cs.stanford.edu>
# Created: 2014-04-25
# Requires: readlink in GNU coreutils
set -eu
self=$(readlink -f "$0")
next=$(type -ap mosh-server | xargs -L1 readlink -f |
grep -vxF "$self" | head -1)
# if Kerberos tickets are available
if klist &>/dev/null; then
# put mosh-server in a Process Authentication Group getting an AFS Token
pagsh -c 'aklog; exec "$@"' -- "$next" "$@"
else
# otherwise, simply call next
exec "$next" "$@"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment