Geralmente, crio o script a seguir em /usr/local/bin
ou $HOME/bin
.
#!/bin/bash
HOSTNAME='uname -n'
ARG='echo $DISPLAY | sed -e "s/localhost/$HOSTNAME\/unix/"'
XAUTH='/usr/bin/xauth -i -f ~/.Xauthority list ${ARG}'
echo "The following is used for graphical displays through ssh."
echo "Copy and paste the following commands AFTER you have \"su - [user]\""
echo "---------------- Copy below ------------------------------------"
echo "DISPLAY=$DISPLAY;export DISPLAY"
echo "/usr/bin/xauth -bi add \"
echo "${XAUTH}"
echo "---------------- Copy above ------------------------------------"
Você executaria esse script antes usando su
ou sudo
. Depois de se tornar o outro usuário, recorte e cole a saída como indicado. Seus programas X
devem ser executados.
[bschuck@dhcp-10-100-11-138 ~]$ bin/xtunnel
The following is used for graphical displays through ssh.
Copy and paste the following commands AFTER you have "su - [user]"
---------------- Copy below ------------------------------------
DISPLAY=localhost:10.0;export DISPLAY
/usr/bin/xauth -bi add \
dhcp-10-100-11-138/unix:10 MIT-MAGIC-COOKIE-1 \
b64ace6b49bb1b49c59679a2db6411eb
---------------- Copy above ------------------------------------
[bschuck@dhcp-10-100-11-138 ~]$ su - zippy
Password:
[zippy@dhcp-10-100-11-138 ~]$ DISPLAY=localhost:10.0;export DISPLAY
[zippy@dhcp-10-100-11-138 ~]$ /usr/bin/xauth -bi add \
> dhcp-10-100-11-138/unix:10 MIT-MAGIC-COOKIE-1
b64ace6b49bb1b49c59679a2db6411eb
[zippy@dhcp-10-100-11-138 ~]$ xclock &
[1] 6076
[zippy@dhcp-10-100-11-138 ~]$