Skip to content

Instantly share code, notes, and snippets.

@kode54
Created August 29, 2018 00:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kode54/9d5cf94f8591c8663f9af367785adfdb to your computer and use it in GitHub Desktop.
Save kode54/9d5cf94f8591c8663f9af367785adfdb to your computer and use it in GitHub Desktop.
Updated the ssh_agent Xsession script in use by Ubuntu, to support restarting the agent when the environment variables still exist, but the daemon has already been stopped.
# $Id: 90x11-common_ssh-agent 305 2018-08-29 00:27:50Z kode54 $
# This file is sourced by Xsession(5), not executed.
STARTSSH=
SSHAGENT=/usr/bin/ssh-agent
SSHAGENTARGS=
if has_option use-ssh-agent; then
if [ -x "$SSHAGENT" ]; then
if [ -z "$SSH_AUTH_SOCK" ] \
&& [ -z "$SSH2_AUTH_SOCK" ]; then
STARTSSH=yes
if [ -f /usr/bin/ssh-add1 ] && cmp -s $SSHAGENT /usr/bin/ssh-agent2; then
# use ssh-agent2's ssh-agent1 compatibility mode
SSHAGENTARGS=-1
fi
else
if ! ps -p "$SSH_AGENT_PID" > /dev/null; then
STARTSSH=yes
if [ -f /usr/bin/ssh-add1 ] && cmp -s $SSHAGENT /usr/bin/ssh-agent2; then
SSHAGENTARGS=-1
fi
fi
fi
fi
fi
if [ -n "$STARTSSH" ]; then
STARTUP="$SSHAGENT $SSHAGENTARGS ${TMPDIR:+env TMPDIR=$TMPDIR} $STARTUP"
fi
# vim:set ai et sts=2 sw=2 tw=80:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment