Skip to content

Display x after user switch

wordpress meta

title: 'Display X After User Switch'
date: '2013-04-12T16:55:36-05:00'
status: publish
permalink: /display-x-after-user-switch
author: admin
excerpt: ''
type: post
id: 279
category:
    - Linux
    - Security
tag: []
post_format: []

Sometimes you find yourself having to redirect the X display to a different host but "ssh -X hostname" will not work since you had to switch users. For instance you logged to a host as root and afterwards "su - oracle".

Example:

$ ssh root@host1.domain.com -X
# echo $DISPLAY
localhost:10.0
# xauth list
host1.domain.com/unix:11  MIT-MAGIC-COOKIE-1  95e4b887f2f6d132897aedbbbe297309
host1.domainom/unix:10  MIT-MAGIC-COOKIE-1  961e9e854127e3c70ff8804a5eb57f7e
# su - oracle
$ xauth add host1.domain.com/unix:10  MIT-MAGIC-COOKIE-1  961e9e854127e3c70ff8804a5eb57f7e
xauth:  creating new authority file /home/oracle/.Xauthority

Then trying xclock or xterm worked for me. If you still have a problem also try:

$ export DISPLAY=localhost:10.0