Last active
August 29, 2015 13:57
-
-
Save synackme/9885702 to your computer and use it in GitHub Desktop.
X11 forwarding after SUDO SU
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# in your login directory on the target machine, add this to your .bashrc: | |
LIVE=`echo $DISPLAY | awk -F: '{print $2}' | awk -F. '{print $1}'` xauth list | grep unix:$LIVE | awk '{print "xauth add " $0}' >xuser |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# su and add this to /root/.bashrc | |
XUSER=`who -m | awk '{print $1}'` | |
XUSERHOME=`grep ^$XUSER: /etc/passwd | awk -F: '{print $6}'` | |
if [ -s "$XUSERHOME/xuser" ]; then | |
. $XUSERHOME/xuser | |
echo Added xauth tokens for display for $XUSER | |
else | |
echo Original user $XUSER left no indication of X job | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment