if [ $UID -gt 0 ]; then # Hack to prevent confusion between two agents when launched from xdm. if [ ! $SHLVL = 1 -o -z "$DESKTOP_SESSION" ]; then # Read a list of hosts which can run an agent from ~/.ssh/agenthosts. if [ -f ~/.ssh/agenthosts ]; then while read allowed; do if [ "${HOSTNAME%%.*}" = "$allowed" ]; then eval $(keychain -q --timeout 7200 --agents ssh --eval) if tty -s; then ssh-add -l >/dev/null || ssh-add fi fi done < ~/.ssh/agenthosts unset allowed fi fi fi