X11 forwarding after su

Moderator: cah

Post Reply
cah
General of the Army / Fleet Admiral / General of the Air Force
General of the Army / Fleet Admiral / General of the Air Force
Posts: 1342
Joined: Sun Aug 17, 2008 5:05 am

X11 forwarding after su

Post by cah »

I was having issues export X apps to local workstation from UNIX servers after su to other users.
It either shows no display or broken X.

I did some research and found the key is the .Xauthority. If I can get it to merge into other users' .Xauthority, the X11 forwarding under SSH would work perfectly.

Attached is a step by step instruction to show users how to get it done with screenshots in it.

The steps are:
  1. Connect to the server as yourself (no special account like root, admin and others)
  2. Find DISPLAY value
    • echo $DISPLAY (keep this for later use)
  3. Change permission on .Xauthority
    • chmod 644 .Xauthority
  4. Become root user by using sudo
    • sudo su
  5. Become app user by using su
    • su - <appuser>
  6. Merge your .Xauthority into this app user’s .Xauthority (it will create a new one if it does not exist)
    • HP-UX: /usr/bin/X11/xauth merge $HOME/.Xauthority ($HOME is your home directory)
    • Solaris: /usr/openwin/X11/xauth merge $HOME/.Xauthority ($HOME is your home directory
  7. Set DISPLAY environment variable
    • HP-UX: setenv DISPLAY xxx.xxx.xxx.xxx:yy.z (value from step 5a)
    • Solaris: export DISPLAY=xxx.xxx.xxx.xxx:yy.z (value from step 5a)
  8. Try to launch X Clock
    • HP-UX: /usr/bin/X11/xclock
    • Solaris: /usr/openwin/X11/xclock
  9. It works if you see the xclock!!
Here comes the attachment with screenshots.
X11 forwarding after su.pdf
(1.14 MiB) Downloaded 322 times
CAH, The Great
Post Reply