X2GoClient uses libssh
and thus is unable to forward SSH Agent credentials by default.
However, there is a workaround:
Put this at the end of /etc/bash.bashrc
on your X2Go Server:
# --- BEGIN X2Go SSH forwarding workaround --- # Part that runs in regular SSH session # check we have an agent socket and # check we have an ~/.x2go directory if [ -n "$SSH_AUTH_SOCK" ] && \ [ -d ~/.x2go ] ; then # touch the output file and set permissions # (as tight as possible) touch ~/.x2go/agentsocket chmod 600 ~/.x2go/agentsocket chown $USER ~/.x2go/agentsocket # write file name of agent socket into file echo $SSH_AUTH_SOCK >~/.x2go/agentsocket fi # Part that runs in X2Go session # check we're on an X2GoServer (x2golistsessions is in path), # check we have a DISPLAY set, and # check our client DISPLAY and SSH client IP correspond to # a running X2Go session and # check ~/.x2go/agentsocket is a regular file if which x2golistsessions >/dev/null && \ [ -n "$DISPLAY" ] && \ [ -n "$(x2golistsessions | \ awk -F '|' '":"$3 == "'$DISPLAY'" && \ $5 == "R" && \ $8 == "'$(echo $SSH_CLIENT | \ awk '{print $1}')'" { print $3 }')" ] && \ [ -f ~/.x2go/agentsocket ] ; then # all checks passed, read content of file # (might still contain stale agent socket or garbage MIGHTBEOURAGENT=$(cat ~/.x2go/agentsocket) # check if it corresponds to an existing socket if [ -S "$MIGHTBEOURAGENT" ]; then # export path to agent socket export SSH_AUTH_SOCK=$MIGHTBEOURAGENT fi fi # ---- END X2Go SSH forwarding workaround ----
Now, start a regular SSH session with Agent Forwarding enabled first, and leave that session running in the background. After that, start X2GoClient and connect to your session. You should now be able to use the Agent Forwarding created with your regular SSH session from inside your X2Go session.
Inherent problems:
There's hope that future versions of X2Go will support SSH Agent Forwarding natively, as a patch to add SSH Agent Forwarding has been submitted to the libssh maintainers in March 2016 - but we will have to wait until that patch makes it into all the major distributions.